Regular database backups protect you from data loss due to software errors, hacking, accidental deletion, or failed updates. There are several ways to back up and restore databases in cPanel.
Please note: Screens and options may vary slightly depending on your cPanel version and hosting plan.
Backing Up via phpMyAdmin
- Go to phpMyAdmin in the Databases section of cPanel.
- Select the database from the left sidebar.
- Click the Export tab.
- Choose Quick (for a standard SQL dump) or Custom (for more control over the export).
- Click Go to download the
.sqlfile.
Backing Up via cPanel Backup
- Go to Backup in the Files section.
- Scroll to Download a MySQL Database Backup.
- Click the database name to download the SQL dump.
Backing Up via SSH (Command Line)
mysqldump -u username_dbuser -p username_database > backup_filename.sql
Replace username_dbuser and username_database with your actual database user and name. You'll be prompted for the password. This method handles large databases more reliably than phpMyAdmin.
For compressed backups:
mysqldump -u username_dbuser -p username_database | gzip > backup_filename.sql.gz
Restoring via phpMyAdmin
- Open phpMyAdmin and select the database.
- If restoring to a fresh database, ensure the database exists and is empty. To empty a database, select all tables and choose Drop from the "With selected" dropdown.
- Click the Import tab.
- Click Choose File and select your
.sqlor.sql.gzbackup file. - Click Go.
Restoring via cPanel Backup
- Go to Backup in the Files section.
- Scroll to Restore a MySQL Database.
- Click Choose File, select your
.sqlfile. - Click Upload.
Restoring via SSH (Command Line)
mysql -u username_dbuser -p username_database < backup_filename.sql
For compressed backups:
gunzip < backup_filename.sql.gz | mysql -u username_dbuser -p username_database
Tips
- Test your backups periodically by restoring them to a test database. A backup you can't restore is useless.
- Automate backups with a cron job for peace of mind.
- Always back up your database before running application updates (WordPress core, plugins, themes, etc.).
- Store backups offsite — don't only keep them on the same server as the database.
- For very large databases, the command-line approach is the most reliable and fastest.
What Next?
- Optimising and Repairing MySQL Databases — Keep your databases healthy.
- Setting Up Cron Jobs — Automate database backups on a schedule.