CPanel Backups

Create Cpanel Backup

(echo;read -p "What is the cPanel username?: " user; /scripts/pkgacct $user; echo -e "\nThe CPanel backup for $user is located at:\n/home/cpmove-$user.tar.gz")

Restore Options

Pull public_html and mysqldumps from CPanel backups

Make sure you are in the directory of backup (ie /backup/[date]/accounts/)

(echo;read -p "What is the cPanel username?: " user; mkdir /home/temp/$user-$(date +"%Y-%m-%d")/;cp -a $user.tar.gz /home/temp/$user-$(date +"%Y-%m-%d")/;cd /home/temp/$user-$(date +"%Y-%m-%d")/;tar -zxf $user.tar.gz $user/homedir/public_html/; echo -e "\nThe public_html is in:\n$(pwd)/$user/homedir/public_html";  tar -zxf $user.tar.gz $user/mysql; echo -e "\nThe MySQL dumps are in:\n$(pwd)/$user/mysql\n")

Copy public_html from temp folder above

Make sure you mv the original public_html aside. ie mv public_html{,.wb.bak}

(echo;read -p "What is the cPanel username?: " user; rsync -av --progress /home/temp/$user-$(date +"%Y-%m-%d")/$user/homedir/public_html /home/$user)

Pull public_html and mysqldumps from cpmove backups

Make sure you are in the directory of backup (ie /home/)

(echo;read -p "What is the cPanel username?: " user; mkdir /home/temp/$user-$(date +"%Y-%m-%d")/;cp -a cpmove-$user.tar.gz /home/temp/$user-$(date +"%Y-%m-%d")/;cd /home/temp/$user-$(date +"%Y-%m-%d")/;tar -zxf cpmove-$user.tar.gz cpmove-$user/homedir/public_html/; echo -e "\nThe public_html is in:\n$(pwd)/cpmove-$user/homedir/public_html";  tar -zxf cpmove-$user.tar.gz cpmove-$user/mysql; echo -e "\nThe MySQL dumps are in:\n$(pwd)/cpmove-$user/mysql\n")

Copy public_html from temp folder above

Make sure you mv the original public_html aside. ie mv public_html{,.wb.bak}

(echo;read -p "What is the cPanel username?: " user; rsync -av --progress /home/temp/$user-$(date +"%Y-%m-%d")/cpmove-$user/homedir/public_html /home/$user)