How to Back Up Your Linux Machine to Box

In a previous article, we took a look at Backintime for KDE, a nice client to automate your back-ups to an external hard drive or other local directory. But it’s good practice to keep a version of your back-ups off-site as well. In this article, we’ll use Deja Dup, the back-up application that comes with Ubuntu, to back up a directory to Box.

Deja Dup is available out-of-the-box from the “System” section of the “System Settings” in Ubuntu Precise.

ubuntu system settings

Clicking on this item will display the “Overview” screen, which shows a couple of default settings, including Ubuntu One as the back-up’s destination, and your entire home directory as what will be backed up. First, let’s change this to just back up your Documents.

dejadup-overview

  • Click on the “Folders” tab
  • This will have your “Home” folder on the left-hand side, under “Folders to Back up,” and “Trash” and “Downloads” on the right-hand side as folders to be ignored.
  • We can delete “Trash” and “Downloads” by selecting them and clicking the “-” button at the bottom of the window. We can also remove the “Home” folder in the same way.
  • Next, click the “+” button on the left-hand side to display a dialog with your home directory folders. Select “Documents” from this window, and click the “Open” button.

dejadup-folders

Next, we’ll change this so the back up is sent to your Box account:

  • Click on the “Storage” tab – this will already set to Ubuntu One
  • Click the “Backup Location” pull-down, and select “WebDAV.”
  • You’ll see some new fields there… fill these in as follows: the server name “www.box.com,” select the option for “Secure Connection,” enter 443 for the “Port,” the folder name where you want to store your back-up, and your Box username.

dejadup-storage-webdav

By default, automatic back-ups are turned off, but if you return to the “Overview” tab, you can test it out by clicking the “Back Up Now” button. Once you’re done, if you visit your Box account, you’ll see three files in the folder you specified:

  • duplicity-full-signatures.[DATE AND TIME].sigtar.gz: This contains some signatures of the files in your backup
  • duplicity-full.[DATE AND TIME].manifest: This contains some information about your backup
  • *duplicity-full.20121015T230958Z.vol1.difftar.gz: Finally, this contains your files

However, you shouldn’t need to worry about these unless you want to “roll back” a change you made. Restoring the folder(s) you selected completely is as simple as selecting the “Restore” button from the “Overview” screen. You can also use the “Schedule” tab to run your back-up daily, weekly, bi-weekly, or monthly.

There are other clients you can use for this as well:

rsync: By combining the directions to automount Box on login located here with the instructions on creating rsync-based backup’s here, we can create a simple shell script to mount the Box share (once you’ve configured it), run the rsync command, then unmount it again:

#!/bin/bash
mount /path/as/configured/in/fstab &&
rsync -avz /folder/you/want/to/backup /path/as/configured/in/fstab &&
umount /path/as/configured/in/fstab

kbackup: This back-up application will, like all KDE apps, take advantage of kioslaves. First, set up your Box account in Dolphin by clicking the “Network” link on the left-hand side. Then, click “Add a Network Folder,” and select “WebDAV” as the protocol. Fill in a name, your username for Box, “www.box.com” for the Server, and “/dav” for the folder. Then, click the “Use encryption” option, and make sure the “Port” number changes to “443″ (as shown in the first figure below). Then click the “Save & Connect” button. On my machine, this will create a shortcut to the Box share and try to open it right away, although this fails for me. But the shortcut does work – use this to visit your Box account, and create a folder for your new backup.

Next, install kbackup with the following command:

sudo apt-get install kbackup

This application is as easy as it gets… on the left-hand side, pick out the folder(s) you want to back-up, then in the “Target -> Folder” field, use the folder button to bring up the file dialog. You can select “Network -> [name of the Box shortcut you created above] -> [folder you want to put the back-up in]” from this dialog, then hit the “OK” button. Hit the big ol’ “Start Backup” button, and you’re off and running.

kbackup-box-backup

With some of the big storage handouts Box has been making, it makes for a good option for cloud-based back-up, with lots of different ways to meet your back-up needs.