Question
How do you restore databases from a daily backup?
Answer
CPANEL_WARN: 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
tarcommand with the-tvfoptions and grep the output for the database name.CONFIG_TEXT: [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 -
User the
tarcommand with the-zxvfoptions 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
- Download the extracted file.
- Log into the user's cPanel account.
- Open phpMyAdmin
- 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
Comments
0 comments
Article is closed for comments.