Notice : You need root access to cPanel server to be able to use this method.
DropBox is my favorite cloud space provider. Their recent price adjustment (1TB for $10/mo) has made using it a no brainer IMO. It is specially very good for backup purposes because it keeps different versions of your files without using any extra space. The retention period for free accounts is 30 days and for pro accounts is 1 year.
So lets say you take a backup of your website and upload it to DropBox everyday and size of your backup is 100MB. if you keep doing it for 1 year, in fact DropBox is keeping 365 x 100MB of your files which you can retrieve any of them while only 100MB of your space is used! it is crazy good, I know.
In order to be able to backup cPanel accounts directly to DropBox, first we need a method to upload files to DropBox from Linux command line. Fortunately there is a very good solution out there to do it : https://github.com/andreafabrizi/Dropbox-Uploader
Please refer to script documentation on how to install it on your server and link it to your DropBox account. it is fairly easy.
After you linked the script to your DropBox Account, move it to /usr/bin folder.
If you want to test it, run the following command and it should show your DropBox account info :
root@X:[~]: dropbox_uploader.sh info Dropbox Uploader v0.14 > Getting info... Name: X X UID: 012345 Email: email@example.com Quota: 1021760 Mb Used: 2611 Mb Free: 1019148 Mb
Now create /usr/bin/backup2db with following content and make it executable :
#!/bin/bash for fn in $1; do /scripts/pkgacct $fn /usr/bin/dropbox_uploader.sh upload /home/cpmove-$fn.tar.gz /cpanel-backup/cpmove-$fn.tar.gz rm /home/cpmove-$fn.tar.gz done
Thats it ! We are good to go.
Command to backup cPanel account acct1 :
It even support multiple account backup :
backup2db 'acct1 acct2 acct3'
If you need daily backups, you can put it in cron :
0 0 * * * /usr/bin/backup2db 'acct1 acct2 acct3' > /dev/null 2>&1