Dropbox is a fantastic tool for syncing data across multiple physical and virtual locations. You can even set up your WHM server to sync all of your backups to your Dropbox account.
1) A Dropbox account.
2) Root access to a WHM server.
Step one: Create a new cPanel account
The first step is to create a new cPanel account. In our example, we’re using the username of dropbox, but you can use whatever domain and username you would like.
Step 2: Disable backups for that account.
Ensure that the Dropbox user is not being backed up in the backup user selection interface.
Step 3: Install and configure Dropbox
Next you want to install the Dropbox client on your new cPanel user’s account. Dropbox provides directions here. We’re going to install the 64 bit daemon, but make sure you chose the one that is right for you. To be clear: this is done via SSH as the cPanel dropbox user, not the root user. Download the tarball, change into that directory, and run the daemon.
firstname.lastname@example.org [~]# wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
--2014-08-30 22:21:45-- https://dl.dropboxusercontent.com/u/17/dropbox-lnx.x86_64-2.10.28.tar.gz
HTTP request sent, awaiting response... 200 OK
Length: 26857327 (26M) [application/octet-stream]
Saving to: “STDOUT”
100%[==================================================>] 26,857,327 1.42M/s in 26s
2014-08-30 22:22:12 (1010 KB/s) - written to stdout [26857327/26857327]
email@example.com [~]# cd .dropbox-dist/
firstname.lastname@example.org [~/.dropbox-dist]# ./dropboxd
This computer isn't linked to any Dropbox account...
Please visit https://www.dropbox.com/cli_link?host_id=fc850fb47f00b2b642 to link this device.
Take the link that’s provided and paste it into any browser. You will be asked to log in to Dropbox, and that will successfully link your account to the server. To make administration of your dropbox folder easier, you can download the CLI script that they provide:
email@example.com [~/.dropbox-dist]# wget -O cli.dropbox.py "https://www.dropbox.com/download?dl=packages/dropbox.py"
firstname.lastname@example.org [~/.dropbox-dist]# chmod +x cli.dropbox.py
Then you start the daemon:
email@example.com [~/.dropbox-dist]# ./dropboxd start
Step 4: Configure backup destination
The final step is to configure your backups to write to your newly configured Dropbox folder. Back in WHM, navigate to your backup configuration interface. You want to set your backup destination to your cPanel’s account’s dropbox folder, which you can see on our server:
firstname.lastname@example.org [~/.dropbox]# pwd
Then you’re all set! Your backups will still be maintained and pruned according to your retention rules. Don’t forget to make sure that your Dropbox account has enough space on it!
This is a great idea which I’m trying implement, however did you not run into issues with syncing because of the file permissions given to the backup files?
As the creator of our backup files is root (the backup script simply copies these over from a queue to our final destination), and we’re running the dropboxd instance as user dropbox, Dropbox can’t actually sync the files as the permissions given to my backup files are 600 (= owner read and write only).
Is this something you’ve run into – did you find a solution (other than I guess running dropboxd as root?)
I didn’t run into that, but it makes logical sense. You might try adding a quick bash script to /scripts/postcpbackup to chown the files. That will correct dropbox/s inability to sync them, however you’ll have problems with restorations if you do that.
Another option would be to set the backup destination back to a more default location, and to use the /scripts/postcpbackup hook to copy the files, and set the correct permissions for dropbox. But you should only do that if you’re sure you have enough disk space.
In case you aren’t familiar with cPanel’s hook system, you can take a look at the list and see a little more about it here.
Definitely let me know if you implement either of those, or if you find another solution!
Many thanks for the quick reply and ideas – I had read up a little on the hooks once I worked out the backed up files weren’t actually being generated from the bash backup script itself. But, as a bash noob I was a bit concerned about being able to implement. Having said that, and thinking about it, it should only be a couple of lines of simple code so I might give it a bash (pardon the pun) when I get a second. In the mean time I am now running dropbox as root which works well and overcomes the problem, but I wanted to ask are there any dangers to this method? In the CLI wiki you reference I noticed it actually recommends installing with root.
Ian, I’m so sorry I missed your question!
I’m not sure there are any real dangers, I am just alway cautious about running applications as root that don’t *need* root access.
Did you go back to running as non-root with a postcpbackup script in place? or are you just running as the root user?
Will the dropbox account be emptied when back-up is finished?
Will I be able to restore back-ups trough the cpanel back-up wizard?
It’s just a regular dropbox folder that is sync’ed to your dropbox account, so not really. The backup system will retain backups in that folder, and will honor your backup retention policy, but it won’t remove the backups just because the backup completes.
Since these are full account backups, you won’t be able to restore the backup from cPanel, you will only be able to restore from WHM.
I couldn’t get this to work 🙁
After putting in: ./dropboxd start
It kept saying This computer isn’t linked to any Dropbox account… Even though I’d already connected it in the steps before.
Any ideas why?
Also I’m a bit confused, how does it know what folder in your dropbox to upload the backups to? Does it create one?
Hi, got this running but how do I set it to backup the files to a specific dropbox sync folder in the cloud and not the default home directory of dropbox?