Remote FTP backups of your WHM/CPanel accounts

Submitted by ivica on Sun, 24.06.2012

So WHM/CPanel has already a very nice build in solution for doing automated local or FTP/SFTP remote backups of your accounts or accounts with all machine configuration files. The only problem is that you can use one of this backup - local or remote, you can not use both. And I wanted to do both stuff - first local backups and then remote FTP backups. Its not that difficulty at all. First thing to do is make sure you configured correctly daily, weekly, monthly backups for local backups in your WHM. If that works then you can add remote FTP backups. For this you will need a shell script that is copying your local baclup files and you need to configure cron then that will execute this script.

An example of daily backup script that is copying all accounts from local daily backup folder (/backup/cpbackup/daily/) to remote ftp folder (/cpbackup/daily)

$ more /root/bin/ftpbackup_daily
ftp -n << EOF
open <ip/domain of your ftp remote server>
user <username> <password>
cd /cpbackup/daily
lcd /backup/cpbackup/daily/
mput *.tar.gz

And I have similar scripts for weekly and monthly backups - it just copy daily backup folder to remote weekly and monthly ftp folders. Before configuring cron you need to change permissions of backup script so it can be executed.

$ chmod 700 /root/bin/ftpbackup_daily

And now cron configuration

$ crontab -e
0 1 * * 3,5,0 /root/bin/ftpbackup_daily > /root/bin/ftpbackup_daily.log
0 2 * * 0 /root/bin/ftpbackup_weekly > /root/bin/ftpbackup_weekly.log
0 3 1 * * /root/bin/ftpbackup_monthly > /root/bin/ftpbackup_monthly.log

So this means that cron will do daily backup copies in 01:00AM every Wednesday, Friday and Sunday (because WHM will do backups on Tuesday, Thursday and Saturday). Weekly backups will be done each Sunday in 02:00 AM and finally monthly backups will be done first day every month in 03:00AM.

For cron syntax and cron command generator you can use or just consult cron manual.

1 comment


I went through the following sites recently

They offer daily incremental backups. The amazing feature of Failsafe being offered by infact automatically undoes any unauthorized modifications done on a website.

Hope this will help out a few people.