How to restore cPanel system backup files? Then ask why cpanel never added the function of restoring the system configuration files that are generated with the cpanel backup feature? We had to do this many times over the years and came across a nice script that works you can use it by just follow the steps below script credit goes to whmclone.com
Be sure to replace ‘DATE’ with the directory that you’d like to restore from!!
ie: /backup/2015-03-04 would be: DATE=’2015-03-04′
Copy and paste this into /usr/local/bin/whm_restore.sh
!/bin/bash
#################################################
#
# WHM/cPanel full server restore script
#
# Version 2015.03.04
#
# You must have backups (not legacy) enabled and
# be running version 11.38 or higher of WHM/cpanel
#
# Run this script as root from anywhere on the
# system to restore all system files and accounts
# from the backups located in /backup/
#
#
#
#################################################
# Change the date here to the date you want to restore from.
DATE=‘2015-03-04′
if [ ! -d “/backup/$DATE” ]; then
echo “Backup directory /backup/$DATE does not exist. Exiting” && exit 1
fi
for dir in /backup/$DATE/system/dirs/*tar.gz; do
tar zxvf $dir -C /
done
echo “Restored system directories…”
for file in /backup/$DATE/system/files/*.gz; do
newfile=$(echo “$file” |
sed -e ‘s,^/backup/’$DATE‘/system/files/,,’ \
-e ‘s,_,/,g’ \
-e ‘s/\.gz$//’)
zcat $file > $newfile
done
echo “Restored system files…”
for account in /backup/$DATE/accounts/*.tar.gz; do
/scripts/restorepkg –skipres –force $account
done
echo “Restored accounts. Do not forget to check account IPs
Then:
chmod +x /usr/local/bin/whm_restore.sh
Run the script by typing:
/usr/local/bin/whm_restore.sh
Before you run this script, I’d like to tell you that you really should know enough to be able to read through it and see what its doing. It does three things:
Restores the system directories located in /backup/$DATE/system/dirs/ directory
Restores the system files located in /backup/$DATE/system/files/ directory
Restores all of the accounts in the /backup/$DATE/accounts/ directory
You can comment out any one of these sections in the file if you only want to do 1 or 2 of the 3 functions.
You also want to make sure the target server is running the same version of software that your old server was – especially the main operating system version because file locations may change from version to version.
If you have any questions on the script, please feel free to comment.