Running Backups
Triggering a Manual Backup
# Run a backup using defaults from config
jokowipe-agent backup --now
# Specify database and storage target
jokowipe-agent backup --now \
--db postgres://user:pass@localhost:5432/mydb \
--storage-target st-a1b2c3
# Back up a named database from config
jokowipe-agent backup --now --database analytics
# Dry run (validate config but don't execute)
jokowipe-agent backup --dry-run
Backup Options
| Flag | Default | Description |
|---|---|---|
--db | Config database.url | Database connection URL |
--database | default | Named database from config |
--storage-target | Config default | Storage target ID |
--retention-days | Schedule setting | Override retention |
--compress | true | Enable compression |
--label | — | Custom label for this backup |
--tag | — | Tags to apply (can use multiple times) |
--timeout | 6h | Max time before backup is killed |
--dry-run | false | Validate without executing |
Monitoring Live Progress
# Watch backup progress in real-time
jokowipe-agent backup --now --follow
# Output:
# 2024-01-15T02:00:01Z INFO Starting backup: bkp-a1b2c3d4
# 2024-01-15T02:00:01Z INFO Connecting to postgres://localhost:5432/mydb
# 2024-01-15T02:00:02Z INFO Running pg_dump...
# 2024-01-15T02:00:44Z INFO pg_dump complete: 142.3 MB uncompressed
# 2024-01-15T02:00:44Z INFO Compressing (gzip -9)...
# 2024-01-15T02:00:45Z INFO Compressed: 34.1 MB (76% reduction)
# 2024-01-15T02:00:45Z INFO Uploading to s3://my-backups/jokowipe/...
# 2024-01-15T02:00:48Z INFO Upload complete (3.1s @ 11.0 MB/s)
# 2024-01-15T02:00:48Z INFO Verifying checksum...
# 2024-01-15T02:00:48Z INFO SUCCESS bkp-a1b2c3d4 (47s, 34.1 MB)
Listing Backups
# List recent backups
jokowipe-agent backup list
# Output:
# ID STATUS SIZE DURATION CREATED
# bkp-a1b2c3d4 success 34.1 MB 47s 2024-01-15 02:00:01 UTC
# bkp-b2c3d4e5 success 33.9 MB 45s 2024-01-14 02:00:01 UTC
# bkp-c3d4e5f6 failed - 12s 2024-01-13 02:00:01 UTC
# List with more details
jokowipe-agent backup list --verbose
# Filter by status
jokowipe-agent backup list --status failed
# Limit output
jokowipe-agent backup list --limit 10
Pre/Post Backup Hooks
Configure shell scripts to run before and after each backup:
hooks:
pre_backup: "/opt/scripts/pre-backup.sh"
post_backup: "/opt/scripts/post-backup.sh"
on_failure: "/opt/scripts/notify.sh"
Pre-Backup Hook
The pre-backup hook runs before the backup command. If it exits non-zero, the backup is aborted.
#!/bin/bash
# /opt/scripts/pre-backup.sh
# Check disk space
AVAIL=$(df /var/tmp --output=avail | tail -1)
if [ "$AVAIL" -lt 10485760 ]; then # 10 GB
echo "ERROR: Insufficient disk space for backup"
exit 1
fi
# Pause application writes (optional)
echo "Pre-backup check passed"
exit 0
Hook environment variables:
| Variable | Value |
|---|---|
JOKOWIPE_BACKUP_ID | Unique backup job ID |
JOKOWIPE_DATABASE_URL | Database being backed up |
JOKOWIPE_AGENT_NAME | This agent's name |
JOKOWIPE_SCHEDULE_ID | Schedule ID (if triggered by schedule) |
Post-Backup Hook
The post-backup hook runs after a successful backup. The exit code is logged but does not affect backup status.
#!/bin/bash
# /opt/scripts/post-backup.sh
echo "Backup $JOKOWIPE_BACKUP_ID completed successfully"
echo "Size: $JOKOWIPE_BACKUP_SIZE bytes"
echo "Duration: $JOKOWIPE_BACKUP_DURATION seconds"
# Optional: send a custom metric to your monitoring system
curl -s -X POST https://metrics.example.com/backup-success \
-d "{\"id\": \"$JOKOWIPE_BACKUP_ID\", \"size\": $JOKOWIPE_BACKUP_SIZE}"
Scheduling via Cron (Alternative)
If you prefer local cron scheduling over the dashboard:
# /etc/cron.d/jokowipe
0 2 * * * jokowipe /usr/local/bin/jokowipe-agent backup --now >> /var/log/jokowipe-backup.log 2>&1
Dashboard Scheduling is Recommended
Dashboard scheduling gives you centralized monitoring, anomaly detection, and missed-backup alerting. Local cron is an alternative if you need more control.
Backup File Format
| Database | Format | Extension | Compression |
|---|---|---|---|
| PostgreSQL | pg_dump custom | .dump | Built-in |
| MySQL | SQL dump | .sql.gz | gzip |
| MongoDB | BSON archive | .archive.gz | gzip |
| Redis | RDB snapshot | .rdb.gz | gzip |
| SQLite | Database file copy | .db.gz | gzip |