Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to restore a user's database from a Plesk backup?
Answer
Note: To extract a user's database from a Plesk backup, follow the command-line instructions.
-
Connect to a Plesk server via SSH.
-
Find the current backup location:
# grep "DUMP_D" /etc/psa/psa.conf
DUMP_D /var/lib/psa/dumps -
Find a database you want to restore with the path from step 2 and a database name using the command below. Replace example_db with an actual database name:
# find /var/lib/psa/dumps/ | grep example_db
The output will look like this:
# find /var/lib/psa/dumps/ | grep example_db
/var/lib/psa/dumps/clients/john_doe/domains/example.com/databases/example_db
/var/lib/psa/dumps/clients/john_doe/domains/example.com/databases/example_db/backup_xxxxxxxxx.tgz -
Extract the database to the
/root
directory with a full path to the database from step 3:# tar -xvf /var/lib/psa/dumps/clients/john_doe/domains/example.com/databases/example_db/backup_xxxxxxxxx.tgz -C /root/
-
To restore a database from this dump, run this command:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin db_example < /path/to/database_dump
where
- /path/to/database_dump - the extracted database dump from step 4
- db_example - the database in which the dump is going to be restored
Additional Information
If there is a hardware backup that contains all files on the server, follow the the following steps:
-
Create a backup of
/var/lib/mysql/
:# cp -a /var/lib/mysql{,.bkp}
-
Stop MySQL server:
# service mariadb stop
# service mysql stop
# service mysqld stop -
Remove the content of
/var/lib/mysql/
:# rm -rf /var/lib/mysql/*
-
Move the files from the backup to
/var/lib/mysql/
:# cp -a /root/backup/mysql/ /var/lib/mysql/
-
Start MySQL server:
# service mariadb start
# service mysql start
# service mysqld start -
Dump required database:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump john_database -uadmin > john_database.sql
-
Stop database server as described in step 2.
-
Remove the content of
/var/lib/mysql/
as described in step 3. -
Move all the backed up content from step 1 back:
# cp -a /var/lib/mysql.bkp/* /var/lib/mysql/
-
Start database server as described in step 5.
-
Import database dump with the following command:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin -e 'CREATE DATABASE john_database' && MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql john_database -uadmin < john_database.sql
Comments
0 comments
Please sign in to leave a comment.