db:restore
Introduction
db:restore replaces the selected productβs database with a .sql or .sql.gz dump, such as one db:dump wrote. It backs up the current database first, so you can always go back.
splent db:restore dump_splentdb_20260101_120000.sql
β οΈ This will overwrite the database 'splentdb' with the contents of 'dump_splentdb_20260101_120000.sql'.
Continue? [y/N]: y
π Pre-restore backup saved to: pre_restore_splentdb_20260930_120000.sql
β
Database restored from: dump_splentdb_20260101_120000.sql
Restoring without a prompt
splent db:restore backups/nightly.sql.gz --yes
Use --yes in scripts and CI. A corrupt .gz archive stops the command before it touches the database.
Going back after a bad restore
Every restore first writes the current database to pre_restore_<database>_YYYYMMDD_HHMMSS.sql in the current directory, readable only by you. If the import fails, the command says so, warns that the database may be inconsistent, and prints the line that brings the backup back.
splent db:restore pre_restore_splentdb_20260930_120000.sql --yes
If the backup itself fails, usually because the database is unreachable, nothing is restored.
Reference
Options
| Option | Description |
|---|---|
FILENAME |
The .sql or .sql.gz file to load |
--yes |
Do not ask for confirmation |
Errors
| Message | What to do |
|---|---|
β Missing env vars: ... |
Run splent product:env --merge --dev to bring the MARIADB_* variables into docker/.env |
β Could not decompress '<file>' (...) |
The archive is truncated or corrupt. Nothing was written |
β Could not create a pre-restore backup of '<database>' ... |
Check that the database is reachable and the credentials are right |
β Error restoring database: ... |
Restore the backup with the command it prints |
Credentials come from the MARIADB_* variables the CLI loads (Precedence in the CLI).
Requirements
- A selected product. Without one it prints
No product selected. Run: splent product:select <name>and exits 1. - A reachable database.