Easily back up or restore system databases in Plesk for Linux and Windows. Take a minute and discover what our Plesk Support Team has to say.
Backup or Restore a System Database in Plesk
Backup and restoration processes play a key role in ensuring data integrity, safeguarding against accidental loss, and facilitating disaster recovery. In fact, Plesk provides multiple methods to back up and restore databases, ranging from exporting SQL dumps to recovering entire subscriptions.
Database Backup Methods
Databases can be backed up in the following ways:
- Exporting a Database Dump (SQL Format)
A database dump in SQL format enables the creation and download of the database as a single file. This dump can be restored into the same or another database. This method is useful for creating portable backups or migrating data.
- Backing Up an Entire Subscription
An entire subscription backup allows storing the data on the Plesk server or a remote FTP server. During restoration, an individual database can be selected for recovery.
- Cloud Backup Solutions
Plesk integrates with several cloud services for off-site storage. For example, you can backup to Cloud Pro in Plesk to store your backups securely offsite.
For AWS users, you can also configure Plesk S3 backups to send your database backups directly to Amazon S3, ensuring data redundancy and accessibility.
Database Restoration Methods
Databases can be restored from either a subscription backup archive or an SQL dump file:
- Importing a Database Dump
This method restores data from an SQL file into any database of the same type (e.g., MySQL or MariaDB).
- Restoring from a Subscription Backup
When restoring from a subscription backup, the specific database to be recovered can be selected.
Backup & Restore Commands in Plesk for Linux
- Creating a Database Dump
plesk db dump database_name > /path/to/dump_name.sql
Example:
Creates a dump of the `psa` database in `/root` with today’s date:
plesk db dump psa > /root/psa_dump.sql
ls /root/psa_dump.sql - Restoring a Database from a Dump
plesk db < /path/to/dump_name.sql
Example:
Restores the `psa` database from `/root/psa_dump.sql`:
plesk db < /root/psa_dump.sql
Backup & Restore Commands in Plesk for Windows Server
- Creating a Database Dump
plesk db dump database_name > C:\path\to\dump_name.sql
Example:
Creates a dump of the `psa` database:
plesk db dump psa > C:\psa_dump.sql
- Restoring a Database from a Dump
plesk db < C:\path\to\dump_name.sql
Example:
Restores `psa` from `C:\psa_dump.sql`:
plesk db < C:\psa_dump.sql
Restoring System Databases from Plesk Daily or Pre-Upgrade Dumps
On Linux
- From Daily Dumps:
Go to daily dump storage:
cd /var/lib/psa/dumps
ls -l mysql.daily*Also, to restore a single system database:
zcat mysql.daily.dump.0.gz | sed -n '/-- Current Database: `psa`/,/-- Current Database:*/p' | plesk db
We can restore a single table with this command:
zcat mysql.daily.dump.0.gz | sed -n '/-- Table structure for table `log_actions`/,/-- Table*/p' | plesk db
To restore all system databases:
zcat mysql.daily.dump.0.gz | plesk db
- From Pre-Upgrade Dumps:
cd /var/lib/psa/dumps
ls -l mysql.preupgrade*
zcat mysql.preupgrade..dump.gz | MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin
On Windows Server
From Daily Dumps:
Go to backup directory:
cd %plesk_dir%MysqlBackup
dir /O:-D
Also, to restore the latest dump:
plesk db < psa-YYYYMMDDHHMMSS.sql
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
Regular database backups are essential for operational stability and business continuity. With Plesk’s built-in tools, backups are stored securely and restoration is streamlined in case of data corruption, accidental deletion, or system failure.
In brief, our Support Experts demonstrated how to back up or restore system databases in Plesk for Linux and Windows.