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.

  1. Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
  2. 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#
  3. 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 -zxvf /path/to/backup/$cpuser.tar.gz $cpuser/mysql/$dbname.sql
  4. Download the extracted file.
  5. Log into the user's cPanel account.
  6. Open the "phpMyAdmin" application.
  7. Click the database name.
  8. Click the "Import" tab.
  9. Click the "Browse" button in the "File to Import" box.
  10. Select the downloaded .sql file.
  11. Click the "Import" button.

 

Additional resources

How to manually extract individual files from a cPanel backup with the tar utility

How to import and export databases via PHPMyAdmin