How to backup/restore a Plesk database dump?

Created:

2016-11-16 12:41:05 UTC

Modified:

2017-05-23 04:46:38 UTC

13

Was this article helpful?


Have more questions?

Submit a request

How to backup/restore a Plesk database dump?

Applicable to:

  • Plesk

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 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

If you want to perform a database backup manually, use the command below:

  • for Plesk 11.5 and newer:

    # plesk db dump DATABASE_NAME > FILE_NAME.sql
  • for Plesk 11 and older:

    # 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 dump:

# plesk db psa < psa.sql

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

If you need to restore all of these three databases, you have to 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.

If you want to perform a database backup manually, use the command below (run Windows command prompt as Administrator):

"%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:

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:

"%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.