#1. Restore Backup From .sh File
- First of all, log into your SSH as a root.
- Create a new .sh file using the below command.
[root@test ~]# touch testbackup.sh
- Open the newly created file using the below command.
[root@test ~]# vi testbackup.sh
- Paste the below script in the testbackup.sh file.
#!/bin/bash
LBLUE='\033[1;34m'
LCYAN='\033[1;36m'
LGREEN='\033[1;32m'
LPURP='\033[1;35m'
LRED='\033[1;31m'
NC='\033[0m'
for files in /home/username/public_html/backup/*; do
if [ -f "$files" ]
then
/usr/local/cpanel/scripts/restorepkg "$files"
printf "${LGREEN} $files Done \n${NC}"
else
printf "${LRED} $files Not Done \n${NC}"
fi
done
- Do not forget to change the path with the path where the file is present that needs to be restored.
- Once done with the modification, press the ESC button on your keyboard and then type :wq! to Save and Close the file.
- Use the below command to hit the newly edited file.
[root@test ~]# ./testbackup.sh
#2. Restore Backup Via Linux Commands
Other than restoring the backups from the Shell script, you can also use simple Linux commands to perform the same task.
- You can easily backup your existing cPanel by following the below command:
[root@test ~]# /scripts/pkgacct username
Change the username with the cPanel username you want to backup and package it into a single file.
- Now, that you already have the backup file transferred to the new server, you can easily restore it by following the below command:
[root@test ~]# /scripts/restorepkg username
- If the backup file is located anywhere else, transfer it to your server, and follow the below command:
[root@test ~]# /scripts/restorepkg /root/user/backup/file.tar.gz
Once you hit the above command, the restoration process will begin and you can view the output as it'll restore all the cPanel accounts present in your tar.gz file.
You can check the blog to know in detail procedure for restoring cPanel backups via SSH.