- Log in to post comments
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 backup 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
#!/bin/sh
ftp -n << EOF
open <ip/domain of your ftp remote server>
user <username> <password>
bin
hash
prompt
cd /cpbackup/daily
lcd /backup/cpbackup/daily/
mput *.tar.gz
bye
EOF
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 http://cron.nmonitoring.com/cron-generator.html or just consult cron manual.
Comments
rsync
Since FreeNAS is capable of being rsync server, why don't you try to use it's native protocol to backup ? Probably ssh compression will speedup things, for example.
P.S. By the way, nice guide, thanks.
P.P.S Beograd is the best !