I was one of the lucky ones who got my hands on a free 50 GB account on Box.com (former Box.net) with their campaign to launch their new Android app (the campaign runs until March 23, 2012). A similar campaign ran earlier with their IPhone/IPad app. Unfortunately, they don't offer a Linux sync app, so here I describe, step by step, how I did some ninja tricks in order to be able to automatically synchronize a certain directory on my harddrive with my Box.com account from my Ubuntu 11.10 (Oneiric Ocelot) installation.
The trick is this: Using WebDav you can mount your Box.com account as if it was a normal harddisc. Then, once mounted, set up an rsync script to synchronize your selected local directory with the WebDav mount. Personally, I use it to keep an always updated online backup of my family photograph directory, which tends to take up several gigabytes, and counting. Just remember, Box.com will only allow each file to take up a maximum of 100 MB for free accounts. Something similar to this procedure will also work for other services that offer WebDav connections, e.g. One.com.
This how-to might work on other versions of Ubuntu, too (maybe even on other flavours of Linux), perhaps with a few changes here and there, or it might not work for you at all, even though your setup is exactly the same as mine. Use with caution, and at your own risk. Be sure to backup your data before attempting this. But here goes...
A. Install and set up WebDav
- Open a terminal window, and install the WebDav file system package:
sudo apt-get install davfs2
- Make sure you can mount as your normal user (not just root)
sudo chmod u+s /sbin/mount.davfs sudo usermod -a -G davfs2 mylinuxusernameOf course, change "mylinuxusername" into your linux user name.
- Tell the system how and where to mount the Box.com account. Edit the /etc/fstab file as root:
sudo gedit /etc/fstabAdd this line to the file:
https://dav.box.com/dav /home/mylinuxusername/box.com davfs rw,user,auto 0 0
- Let the system know your Box.com user name and password to enable automatic mounting. Edit the /etc/davfs2/secrets file as root and add this line:
https://dav.box.com/dav myboxusername myboxpassword
- Tell WebDav not to use locks, as this won't work with Box.com. Edit the /etc/davfs2/davfs2.conf file as root and add this line:
- Make the mountpoint (an empty directory) for the Box.com account, and mount for the first time:
cd ~ mkdir box.com mount box.com
B. Create a sync script and make it execute once an hour
- Create a script that synchronizes your local directory of choice with the Box.com account. Create a new text file somewhere which will contain the command(s) to do the sync. I suggest ~/bin/boxcomsync . Add the following lines to the file:
#!/bin/bash rsync -avr --delete /home/mylinuxusername/directorytosync/ /home/mylinuxusername/box.com/This will put the files in the root of your Box.com account. You can also create a directory in Box.com and sync the files to there instead. If you want several local directories synced, you can repeat the rsync line for every directory.
- Make the script executable:
chmod u+x ~/bin/boxcomsync
- Test your script to see if everything works as expected. Also, if you have a lot of data to sync, it is probably best to do the first run manually, so that the automated runs will only handle changes to the synced files.
- Set up a cronjob to run the sync script every hour. Run the command:
crontab -eA text editor will appear (probably nano). Add the following line to the file which has been opened, save, and exit the editor.
0 * * * * /home/mylinuxusername/bin/boxcomsyncSee e.g. this guide with examples of how to set other times. Don't set it too often, though, as one run must have time to finish before another is executed.