OpsVault

restore

Restore a database from a local backup file.

The restore command restores a gzip-compressed SQL dump to the target database. It uses the database connection settings from your config file, so you don't need to re-enter credentials.

Restore overwrites the target database. All existing data will be replaced by the contents of the backup file. There is no undo. Make sure you are restoring to the correct database before confirming.

restore run

opsvault restore run --name <database> --file <path> [flags]

Flags

FlagRequiredDescription
--nameyesDatabase name as defined in config
--fileyesPath to the .sql.gz backup file
-y, --yesnoSkip the confirmation prompt

Example

opsvault restore run \
  --name myapp_prod \
  --file /var/backups/opsvault/myapp_prod_20240115_020001.sql.gz

OpsVault shows a summary before proceeding:

  ⚠  This will overwrite the target database. All existing data will be replaced.

  Database:   myapp_prod
  Target:     myapp (backup_user @ 127.0.0.1:5432)
  File:       /var/backups/opsvault/myapp_prod_20240115_020001.sql.gz (4.2 MB)

  ? Type yes to confirm:

Type yes and press Enter to proceed. Anything else aborts.

Skip confirmation

Use --yes to restore non-interactively (e.g. in a script):

opsvault restore run --name myapp_prod --file ./backup.sql.gz --yes

What it does

  1. Opens the .sql.gz file and decompresses it on the fly
  2. Pipes the SQL into mysql (MySQL) or psql (PostgreSQL)
  3. Uses the same password security as backup — temp .my.cnf for MySQL, PGPASSWORD env var for PostgreSQL

Finding backup files

Use backup list to see available local files:

opsvault backup list

Or check backup history to find a specific point in time:

opsvault backup history --db myapp_prod

On this page