Question
How to restore all MySQL / MariaDB user databases from a Plesk backup?
Answer
-
Connect to your Plesk server via SSH.
-
Download the script to your server:
# wget https://support.plesk.com/hc/en-us/article_attachments/29158452093463 -O restore-all-db-plesk-backup.zip
-
Unzip it:
# unzip restore-all-db-plesk-backup.zip
-
Make the script executable:
# chmod +x restore-all-db-plesk-backup.sh
-
Find the current backup location:
# grep "DUMP_D" /etc/psa/psa.conf | grep -v "#"
DUMP_D /var/lib/psa/dumps -
List all available database backups:
Note: If custom backup location is used, replace
/var/lib/psa/dumps
with the path from step 5.# find /var/lib/psa/dumps -name "backup_sqldump_*" -type f -printf '%fn' | sort | uniq
File name contains the date the backup has been taken. For example, timestamp in file
stands for "January 12, 2025, 04:22 AM"
backup_sqldump_2501120422.tzstNote: The most recent backup will be at the end of the output.
-
Open the downloaded script in a text editor. In this example, we are using vi editor:
# vi restore-all-db-plesk-backup.sh
-
Replace the backup name in the
TIMESTAMP
line:TIMESTAMP=backup_sqldump_timestamp.tzst
with the backup name you wish to restore the databases. For example:
TIMESTAMP=backup_sqldump_2501120422.tzst
-
If custom backup location is used, change the value of
DB_PATH
from/var/lib/psa/dumps
to the path from step 5. -
Save the changes and close the file.
-
Dry run the script:
# ./restore-all-db-plesk-backup.sh
-
Check the list of the databases to be restored.
-
Open the script in a text editor again:
# vi restore-all-db-plesk-backup.sh
-
Change the
DRYRUN
value from1
to0
. -
Save the changes and close the file.
-
Run the scrip:
# ./restore-all-db-plesk-backup.sh