Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to create a dump of a database in Plesk?
How to restore a database from a database dump?
Answer
To back up/restore a database, connect to a Plesk server via SSH (Linux) / RDP (Windows Server) and follow the instructions below:
Note: To restore Plesk system databases from a Plesk daily/pre-upgrade dump, visit this KB article.
-
Creating a database dump
# plesk db dump <database_name> > /path/to/<dump_name>.sql
Example
The following command creates a database dump of the Plesk 'psa' database in the/root
directory with today's timestamp:# plesk db dump psa > /root/psa_dump.sql
The following database dump will be created:
# ls /root/psa_dump.sql
psa_dump.sql -
Restoring a database from a database dump
# plesk db < /path/to/<dump_name>.sql
Example
The following command restores the Plesk psa database from the database dump 'psa_dump.sql' located in the/root
directory:# plesk db < /root/psa_dump.sql
-
Creating a database dump
C:\> plesk db dump <database_name> > C:/path/to/<dump_name>.sql
Example
The following command creates a database dump of the Plesk 'psa' database onC:\
drive:C:\> plesk db dump psa > C:\psa_dump.sql
-
Restoring a database from a database dump
Use this command:
C:\> plesk db < C:/path/to/<dump_name>.sql
Example
The following command restores the Plesk 'psa' database from the database dumppsa_dump.sql
located onC:\
drive:C:\> plesk db < C:\psa_dump.sql
C:\> cd %plesk_dir%Mysql\Backup
Comments
10 comments
I have a issue when i try to do this command included in a crontab
plesk db dump DATABASE_NAME > C:\FULL\PATH\TO\FILE_NAME.sql
when I execute manually the command runs perfect and i can backup all my sql files, but when i use this comend inside a crontab, they create and retund the .sql files empty
Thank you.
@Alex Rubio Cazador
Try using the full path to the executable instead of the alias:
For Linux:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin DATABASE_NAME > /full/path/to/BACKUP_FILE_NAME.sql
For Windows Server:
C:\>"%plesk_dir%\Mysql\bin\mysqldump.exe" -uadmin -p<plesk_admin_password> -P8306 DATABASE_NAME > C:\FULL\PATH\TO\FILE_NAME.sql
hai am new to plesk am getting error while am updating plesk
Internal error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'psa.ServiceInstallations' doesn't exist
how to rectify this error
Hello @santhosh,
This behavior may be caused by several issues:
# free -m
# cat /proc/user_beancounters
There should be enough memory and all 'failcnt' values should be 0.
Do the following in order to fix the issue:
Check this article for reference:
https://support.plesk.com/hc/en-us/articles/360006408573-Unable-to-open-Plesk-after-upgrade-Table-psa-ServiceInstallations-doesn-t-exist
Can i use this to restore a domain that was deleted?
Hello @iamkingsleyf,
For restoring whole domain (subscription) it is required to use the backup, created by backup manager.
Navigate Tools & Settings > Backup Manager > select required backup and choose the subscription you need to restore.
Use the following articles as reference:
https://support.plesk.com/hc/en-us/articles/115000340534-How-to-create-and-restore-the-backup-for-certain-subscription-domain-
https://docs.plesk.com/en-US/12.5/administrator-guide/advanced-backing-up-and-recovering-websites/restoring-backups.65200/
Please note that ...
plesk db dump <database_name> > /path/to/<dump_name>.sql
... and the respective ...
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -uadmin <database_name> > /path/to/<dump_name>.sql
.. as well as the backups generated in the backup manager (I assume the same tools are used) will not backup created events.
To include events use
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -uadmin <database_name> --events > /path/to/<dump_name>.sql
Would be nice to see this added to the the backup manager as I was quite astonished to see that my database backups do not contain events.
Hello @Sergio Sanchez,
Thank you for your suggestion.
I've created User voice request for this feature
https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/37900933-include-mysql-events-in-plesk-backups
Please vote for this suggestion and feel free to discuss it there, the top-ranked suggestions are likely to be included in the next versions of Plesk.
Tengo problemas con el volumen de copias de seguridad que genera y me quedo sin memoria. Como configuro para que solo se deje la ultima copia de seguridad y no se acumulen las antiguas?
Hola Gabriel
Puedes encontrar la informacion en la siguiente guia https://support.plesk.com/hc/en-us/articles/115001279669-How-to-limit-the-number-of-server-wide-backups-stored-in-Plesk
Please sign in to leave a comment.