Restore a MySQL backup

Understand how to restore your MySQL Backups

 

This is a quick example of how to restore a MySQL database dump of a single database.

⚠️
WARNING: This restore process may overwrite your database by the backed up copy you are restoring.

Step 1 - Create a MySQL Database

Create a MySQL backup for sampleDatabase  (as an example).

Step 2 - Copy your backup link

  • Go to your backup page, then select the "Logs" tab. Afterwards, click the little "( i )" on the right next to the copy you want to download.
 
  • Under the backup restore section on the modal that just popped up, click on "Click to generate a signed download link" then copy the resulting link.
⚠️
Note: if your backup creates multiple files (for example, backing up all databases but also not dumping them all together, then you need to find the signed link for each database by following this tutorial.

Step 3 - Download your backup file

On your server, run the following command, and use the signed download link you obtained in the previous step (ensure you enclose it in double quotes as shown):

wget "PasteTheSignedDownloadLinkHereBetweenTheQuotes" -O "mysql-backup.sql.gz"

Step 4 - Uncompress your backup file

Now that you downloaded the database backup on your server, extract it as shown:

tar -xvf mysql-backup.sql.gz

This will output a single SQL file in this format db-backup-XXX.sql in the same directory.

Step 5 - Restore your backup

⚠️
The following command will overwrite your sampleDatabase by the database copy you are restoring. It is a good practice to inspect the backup first before the restore.

Restore and overwrite your by the downloaded backup as shown below by running:

mysql -uYOURDATABASEUSERNAME -pYOURDATABASEPASSWORD < db-backup-XXX.sql

If you need any help in any of these steps, let us know and we can help you with the restore.

Did this answer your question?
😞
😐
🤩

Last updated on August 6, 2021