OpsVault

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 run

Run a single database or path by name:

opsvault backup run myapp_prod       # database
opsvault backup run myapp_uploads    # path backup

Output

  ✓  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 $PATH

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

  1. Runs mysqldump or pg_dump and pipes output through gzip → .sql.gz
  2. Writes to a .tmp file first, then renames atomically to prevent partial files

For each enabled path:

  1. Walks the directory tree, skipping excluded patterns
  2. Creates a .tar.gz archive with file permissions preserved
  3. Writes atomically via .tmp rename

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

Both .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: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