Introduction
The following procedure provides the steps to restore a database from a daily cPanel backup.
Procedure
Please note that in the following examples, "/path/to/backup/" must be replaced with the path to the stored backup file, "$cpuser" must be replaced with the cPanel user's username, and "$dbname" must be replaced with the name of the database to restore.
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Run the
tar
command with the-tvf
options and grep the output for the database name.[root@server ~]cPs# tar -tvf /path/to/backup/$cpuser.tar.gz|grep $dbname
-rw------- root/root 1494 2024-07-09 02:00 $cpuser/mysql/$dbname.create
-rw-r--r-- root/root 61043 2024-07-09 02:00 $cpuser/mysql/$dbname.sql
[root@server ~]cPs# - User the
tar
command with the-zxvf
options and the path to the database's .sql file, found in the previous step, to extract the .sql file.tar -tvf /path/to/backup/$cpuser.tar.gz $cpuser/mysql/$dbname.sql
- Download the extracted file.
- Log into the user's cPanel account.
- Open the "phpMyAdmin" application.
- Click the database name.
- Click the "Import" tab.
- Click the "Browse" button in the "File to Import" box.
- Select the downloaded .sql file.
- Click the "Import" button.
Additional resources
How to manually extract individual files from a cPanel backup with the tar utility