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
| Flag | Required | Description |
|---|---|---|
--name | yes | Database name as defined in config |
--file | yes | Path to the .sql.gz backup file |
-y, --yes | no | Skip the confirmation prompt |
Example
opsvault restore run \
--name myapp_prod \
--file /var/backups/opsvault/myapp_prod_20240115_020001.sql.gzOpsVault 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 --yesWhat it does
- Opens the
.sql.gzfile and decompresses it on the fly - Pipes the SQL into
mysql(MySQL) orpsql(PostgreSQL) - Uses the same password security as backup — temp
.my.cnffor MySQL,PGPASSWORDenv var for PostgreSQL
Finding backup files
Use backup list to see available local files:
opsvault backup listOr check backup history to find a specific point in time:
opsvault backup history --db myapp_prod