How to backup/restore a Plesk database dump

Created:

2016-11-16 12:41:05 UTC

Modified:

2017-08-17 06:39:26 UTC

17

Was this article helpful?


Have more questions?

Submit a request

How to backup/restore a Plesk database dump

Question

How to backup/restore a Plesk database dump?

Answer

Plesk for Linux:

Automatic Plesk database dumps are stored in the directory defined by the DUMP_D variable value in the /etc/psa/psa.conf file.

There are two types of automatic dumps:

  1. Daily dumps that are made every night, together with running of the statistics utility. Dump files have names like mysql.daily.dump.1.gz located in /var/lib/psa/dumps/ by default and each file includes a dump of three databases:

    • psa
    • horde
    • mysql
  2. Pre-upgrade dumps that are made when the Plesk package update is run. Dump file names look like mysql.preupgrade.<version and time stamp>.dump.gz , and each file includes a dump of:

    • mysql
    • psa
    • apsc

Connect to the server using SSH and use the command below to perform a database backup manually:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin DATABASE_NAME > FILE_NAME.sql

The example below shows how to restore ' PSA ' database from the daily dump:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa < mysql.daily.dump.0

The following example shows how to restore ' PSA ' database from the pre-upgrade backup file:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -e"DROP DATABASE psa;"
# zcat /var/lib/psa/dumps/mysql.preupgrade.<version and time stamp>.dump.gz | sed -n '/-- Current Database: `psa`/,/-- Current Database:*/p' | MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -f -uadmin

In case restoring all of three databases, delete them before restoration using the DROP DATABASE SQL command.

Plesk for Windows:

Automatic Plesk database dumps are stored in the "%plesk_dir%"/Mysql/Backup directory.

Connect to the server using RDP and use the command below (run Windows command prompt as Administrator) to perform a database backup manually:

C:\> "%plesk_dir%"/Mysql/bin/mysqldump.exe -uadmin -p<plesk_admin_password> -P8306 DATABASE_NAME > FILE_NAME.sql

Since Plesk 12.5 the shortcut command is available for backup creation:

C:\> plesk db dump DATABASE_NAME > FILE_NAME.sql

The following example shows how to restore the "%plesk_dir%"\MySQL\Backup\psa-20131202194200.sql backup file:

C:\> "%plesk_dir%"/Mysql/bin/mysql.exe -uadmin -p<plesk_admin_password> -P8306 psa < "%plesk_dir%"/Mysql/Backup/psa-20131207194200.sql

Have more questions? Submit a request
Please sign in to leave a comment.