OpsVault

backup

Run and list database backups.

backup run

Run a backup immediately, outside of the normal schedule.

opsvault backup run [database-name] [flags]

Run all enabled databases:

opsvault backup run

Run a single database by name:

opsvault backup run myapp_prod

Output

  ✓  myapp_prod  (1.8s)
       /var/backups/opsvault/myapp_prod_20240115_020001.sql.gz

  ✗  analytics  (0.3s)
       starting pg_dump: exec: "pg_dump": executable file not found in $PATH

backup run processes every database even if one fails — it does not stop on the first error. The exit code is 1 if any database failed.

What happens during a run

  1. For each enabled database:
    • Runs mysqldump or pg_dump and pipes output through gzip
    • Writes to a .tmp file first, then renames atomically to prevent partial files
  2. If rclone is enabled: uploads to the configured remote
  3. If local retention is enabled: prunes old local files
  4. If remote retention is enabled: prunes old remote files
  5. 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     MODIFIED

  myapp_prod_20240115_020001.sql.gz          4.2 MB   2024-01-15 02:00
  myapp_prod_20240114_020001.sql.gz          4.1 MB   2024-01-14 02:00
  myapp_prod_20240113_020001.sql.gz          4.0 MB   2024-01-13 02:00

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:01

Flags

FlagDefaultDescription
-n, --limit50Maximum 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.

On this page