### # cPanel Backup via Cron v1.2.1 ### ### # Instructions ### # Make sure CP_SCP_BACKUP_ROOT directory exists. It is "web_backup" by default. # Within this directory you'll need a directory for each cPanel account you're # backing up. # # I.e. if you're backing up "example.com" and "foobar.com" and you want them # to be backed up in the default location of "web_backup", you'll need to # execute the following commands at the recieving end: # mkdir ~/web_backup # mkdir ~/web_backup/example.com # mkdir ~/web_backup/foobar.com ### ### # Config begins ### #cPanel info -- host that is being backed up CP_USERNAME=username CP_PASSWORD=password CP_DOMAIN=yourdomain.com CP_SKIN=x3 # plain "x" is probably the most common one #SCP/FTP info -- host to receive the backup file CP_SCP_USER=username CP_SCP_PASS=password CP_SCP_HOST=backup-host.com CP_SCP_PORT=22 # see cPanel backup page for alternatives of transfer mode CP_SCP_MODE=scp # email address for sending notification after backup is completed CP_EMAIL=webmaster@example.com # target directory on remote host; do not include domain names in this one CP_SCP_BACKUP_ROOT=web_backup%2F # url encoded, e.g. "/" equals "%2F" ### # Config ends ### # creates the target path (directory and filename) # if you make changes, remember to url encode slashes, i.e. "/" equals "%2F" # if --year option is used, script creates a yearly filename, otherwise a monthly one if [ "$1" = '--year' ]; then CP_SCP_RDIR=$CP_SCP_BACKUP_ROOT$CP_DOMAIN%2F$CP_DOMAIN-year-`date +%Y`.tar.gz else CP_SCP_RDIR=$CP_SCP_BACKUP_ROOT$CP_DOMAIN%2F$CP_DOMAIN-month-`date +%m`.tar.gz fi # initiate backup (the following command should be on one line) curl --silent --insecure --user $CP_USERNAME:$CP_PASSWORD -d "dest=$CP_SCP_MODE&email=$CP_EMAIL&server=$CP_SCP_HOST&user=$CP_SCP_USER&pass=$CP_SCP_PASS&port=$CP_SCP_PORT&rdir=$CP_SCP_RDIR" https://$CP_DOMAIN:2083/frontend/$CP_SKIN/backup/dofullbackup.html > /dev/null # gets curl return code CURL_EXIT=$? # curl encountered an error if [ $CURL_EXIT -gt 0 ]; then echo curl returned exit status $CURL_EXIT - see curl manual pages for more details exit 69 fi # everything ok exit 0