backup
Run and list database and path backups.
backup run
Run a backup immediately, outside of the normal schedule. Runs all enabled databases and all enabled paths.
opsvault backup run [name] [flags]Run everything (all databases + all paths):
opsvault backup runRun a single database or path by name:
opsvault backup run myapp_prod # database
opsvault backup run myapp_uploads # path backupOutput
✓ myapp_prod (1.8s)
/var/backups/opsvault/myapp_prod_20240115_020001.sql.gz
✓ myapp_uploads (3.2s)
/var/backups/opsvault/myapp_uploads_20240115_020001.tar.gz
✗ analytics (0.3s)
starting pg_dump: exec: "pg_dump": executable file not found in $PATHbackup run processes every target even if one fails — it does not stop on the first error. The exit code is 1 if any target failed.
What happens during a run
For each enabled database:
- Runs
mysqldumporpg_dumpand pipes output through gzip →.sql.gz - Writes to a
.tmpfile first, then renames atomically to prevent partial files
For each enabled path:
- Walks the directory tree, skipping excluded patterns
- Creates a
.tar.gzarchive with file permissions preserved - Writes atomically via
.tmprename
After all targets:
4. If rclone is enabled: uploads each file to the configured remote
5. If local retention is enabled: prunes old local .sql.gz and .tar.gz files
6. If remote retention is enabled: prunes old remote files
7. Sends notifications (if configured)
Global flags
--config string path to config file (default: /etc/opsvault/config.yaml)backup list
List the local backup files stored in backup_dir.
opsvault backup list [flags]Output
FILE SIZE TYPE MODIFIED
myapp_uploads_20240115_020001.tar.gz 14.2 MB path 2024-01-15 02:00
myapp_prod_20240115_020001.sql.gz 4.2 MB db 2024-01-15 02:00
myapp_prod_20240114_020001.sql.gz 4.1 MB db 2024-01-14 02:00Both .sql.gz database archives and .tar.gz path archives are shown. Files created in the last 24 hours are highlighted in green.
backup history
Show the history of past backup runs — successes and failures — with duration, file size, and timestamps.
opsvault backup history [flags]Output
DATABASE STATUS SIZE DURATION STARTED AT
────────────────────────────────────────────────────────────────────────
myapp_prod success 4.2 MB 1.8s 2024-01-15 02:00:01
analytics success 1.1 MB 0.9s 2024-01-15 02:00:03
myapp_prod failed - 0.2s 2024-01-14 02:00:01
└─ starting pg_dump: exec: "pg_dump": executable file not found in $PATH
myapp_prod success 4.1 MB 1.7s 2024-01-13 02:00:01Flags
| Flag | Default | Description |
|---|---|---|
-n, --limit | 50 | Maximum number of entries to show |
--db | (all) | Filter by database name |
Storage
History is stored as newline-delimited JSON in <backup_dir>/.history.jsonl. Each backup run appends one entry. The file is never truncated automatically — use --limit to cap the output.