Friday, 8 March 2013

CPanel Backup via remote FTP bash script

 cPanel Backup via remote FTP -- This script will generate full cpbackup and then copy it to the remote ftp server. You can also use SCP as an alternate backup transfer method. Simply made the changes in transfer mode and the port no(i.e, MODE and PORT)

 #cPanel info -- host that is being backed up
 CP_DOMAIN=domainname or ip
 CP_SKIN=x3 # plain "x" is probably the most common one
 #FTP info -- host to receive the backup file
 CP_FTP_HOST=domainname or ip
 # backup transfer mode
 # email address for sending notification after backup is completed
 # target directory on remote host; do not include domain names in this one
 # initiate backup (the following command should be on one line)
 curl --silent --insecure --user $CP_USERNAME:$CP_PASSWORD -d
 https://$CP_DOMAIN:2083/frontend/$CP_SKIN/backup/dofullbackup.html > /dev/null
 # gets curl return code
 # 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
 # everything ok
 exit 0