Restore a database
Brings back one MySQL database of an account from a backup: into a new database, next to the current one (the default), or replacing the current one. It can also bring back only some tables, or restore just to check that the backup opens and then delete the copy.
● available ● Only to test and Delete the restored database: 0.4.175 ● Streamed restore: 0.4.201 cPanel and DirectAdmin (from a JetBackup backup: cPanel only).
On the screen
Accounts › the account › the backup › the database › Restore. Download .sql gets the dump without restoring anything.
| Option | What it does |
|---|---|
| Into a new database (default) | creates the database (suggested: <database>_restDDMM, with the account prefix; on cPanel through the panel, on DirectAdmin straight in MySQL, with access for the account's users); the current database is not touched; the same users get access to the new one |
| Only to test (only with Into a new database) | after checking the rows, the Salvo deletes the new database (the result stays in the history). Only with the whole database: if you mark some tables, it is off |
| Replace database db | the current content is replaced by the backup's; check I understand…. Salvo keeps a compressed safety copy of the current database first (in <state>/safety); a deleted database is recreated |
| Only these tables (optional) | mark the tables; the others stay as they are. With Replace, the safety copy is still of the whole database. Routines, events and views are not restored with tables |
Click Restore database (or Restore the tables). The restore opens with the tables and rows before and after. With Only to test, it ends with Test database deleted after the check.
Streamed or through the work folder
By default the whole database comes out of the storage and goes into MySQL at the same time, without going through the work folder, and the restore shows the table being imported (0.4.201). Its steps are Read from the backup and import, Check the rows of each table and, with Only to test, Delete the test database (0.4.207). To go back to the old way (export the whole database to the work folder, then import it): Settings › Restore › Stream database restores › No › Save (0.4.202). Restoring only some tables and restoring from a JetBackup backup always use the work folder.
Tables imported at once when restoring a database (same screen, 1 to 8, default 2; 0.4.204): in a streamed restore, the tables go into MySQL through up to this many connections at once, each using one core. Each large MyISAM table gets its own connection; the InnoDB tables stay together in one. 1 = one table at a time. More connections, more server load during the restore.
Measured with the same 6.4 GB database (94 tables) on a server with 2 cores and 3.6 GB of RAM; every round checked 94 of 94 tables with no row difference:
| How | Time | Work folder at peak |
|---|---|---|
| Through the work folder | 46 min 51 s | 14.3 GB |
| Streamed | 46 min 38 s | 0 |
| Streamed, rebuilding a large MyISAM table's index once (0.4.203) | 30 min 35 s | 0 |
| Streamed, with 2 connections (0.4.204) | 24 min 56 s | 0 |
Delete the restored database
When a restore into a new database ends and the database is still on the server, the restore shows The database X is still on the server with Delete the restored database. It asks for confirmation (Delete now) and the app code, and goes to the Audit. It deletes only the database the restore created, never the original nor a database that already existed (on DirectAdmin, only a database with the account prefix).
From a JetBackup backup
The backups JetBackup left on the storage are restored the same way (cPanel only): Accounts › the account ›
JetBackup backups › the backup › Restore database. Same options: Into a new database (suggested:
<database>_jb<DDMM of the backup>), Only to test, Replace database and Only these tables (optional, one per
line) (0.4.176).
# the JetBackup backups of the account (ID = the backup id)
/var/lib/salvo/salvo jb-legacy-backups --account USER
# only to test, or with --table T (repeatable), or --mode replace
/var/lib/salvo/salvo jb-legacy-restore-database --account USER --backup ID --database DB --mode new --test
On the command line
# into a new database (the account prefix is added), only to test: deleted after the row check
/var/lib/salvo/salvo restore-database --job ID --account USER --database DB --mode new --target NEWDB --test
# into a new database, kept
/var/lib/salvo/salvo restore-database --job ID --account USER --database DB --mode new --target NEWDB --note "why"
# replace the current database (a safety copy is kept first); --execution N picks an older backup
/var/lib/salvo/salvo restore-database --job ID --account USER --database DB --mode replace --execution N
# only some tables (repeat --table)
/var/lib/salvo/salvo restore-database --job ID --account USER --database DB --mode new --target NEWDB --table wp_posts --table wp_postmeta
# delete the database a restore into a new database created (N = the restore number)
/var/lib/salvo/salvo restore-drop-database --restore N
# go back to the old way (export to the work folder, then import); sim turns streaming on again
/var/lib/salvo/salvo config --set restore_banco_fluxo=nao
# tables imported at once in a streamed restore (1 to 8, default 2)
/var/lib/salvo/salvo config --set restore_banco_conexoes=2
--testworks only with--mode newand the whole database: with--mode replaceit is refused.- A restored database that you keep uses space on the server and has the same users as the original. If it was only to check, delete it when you finish.
- A database Salvo deleted itself (Delete the restored database or Only to test) does not raise the database gone from the account warning in the next backups (0.4.177). If a backup caught it, that backup stays restorable until the retention deletes it.