Dropbox

January 12, 2011 at 5:03 am 4 comments

| Gabriel |

I’ve started playing with Dropbox lately. This is useful both as backup and as a user-friendly (but limited capacity) alternative to RCS on the Subversion model. The way it works is that Dropbox creates a folder called ~/Dropbox, then syncs everything in that folder to the cloud. The trouble is how I integrate it into my existing file system. Here are a few options:

  1. Hard links. That is, basically have the same file be located in two places at once. This seems ideal but is actually a bad idea since hard links can be broken pretty easily and you end up with two files rather than one file in two places. The only thing I’m comfortable using hard links for is incremental backup (as in my time-stamped scraping workflow), but I try not to use them in an active file system where all sorts of programs are doing God knows what to the file system.
  2. Symbolic links to ~/Dropbox. That is, keep my files where they were and put a symbolic link in ~/Dropbox. This is really easy to script and generally low hassle. The downside to this is that it can screwed up if you’re using Dropbox to sync between two computers.
  3. Symbolic links from ~/Dropbox. That is, keep the file in ~/Dropbox and put a symbolic link in the original location. The appeal is that it solves the problem noted above. The problem is that this kills any relative paths from the document. For instance, my book is a Lyx file that links to rather than contains the graphs. The graphs are specified as relative paths and so Latex can’t find them if I keep the file itself in ~/Dropbox and put a symlink in ~/Documents/book. Furthermore, in any kind of file browsing at the original location, the file type shows up as a symbolic link rather than a “Lyx Document,” “Stata do-file,” or whatever. I can still tell what it is by the icon and extension, but I can’t sort by file type.
  4. Two copies, synced with Unison. Instead of linking, keep a copy of the file in both the original location and in ~/Dropbox. Then cron Unison to ensure that they are always current. The problem with this is that I’m using Dropbox in part to avoid having to learn how to script Unison.

Of these, #4 (Unison) strikes me as the most elegant but for my needs #2 (symlinks in ~/Dropbox) is the most practical and I’m too busy right now to really get my geek on. I’m almost always using my MacBook and on those rare occasions when I’m using another computer, I’ll just treat the main directories on the Dropbox cloud as read-only and then manually sync the updates to my Macbook’s original file system (and by extension, ~/Dropbox and the Dropbox cloud). If I ever get into a situation of regularly using multiple computers, I’ll probably do the Unison thing. Alternately, I could just pay $20/month to buy such a massive Dropbox account that I could basically treat it as my ~/Documents folder, which would eliminate the issue altogether.

Anyways, for now, I’m just keeping everything where it is and adding symbolic links to ~/Dropbox. To make this really easy, I used Automator to save this script as a right-clickable Finder (or PathFinder) service so I can easily send a symbolic link of a file to my ~/Dropbox directory.

#bin/bash
for f in "$@"
do
	FILENAME=`basename $f`
	DIRPATH=`dirname $f | sed 's/  *//g' | sed 's/\//\./g' | sed 's/^.//'` 
	ln -s "$f" ~/Dropbox/$DIRPATH.$FILENAME
done

This script creates a symbolic link inside ~/Dropbox. The symbolic link is named for the full path of the linked file, but with spaces suppressed and with all “/” (except the leading one) turned into “.” . For instance, if I apply the service to a file called:

/Users/rossman/Documents/book/book.lyx

it creates a symbolic link to this file called

/Users/rossman/Dropbox/Users.rossman.Documents.book.book.lyx

It also works on directories, eg, this:

/Users/rossman/Documents/miscservice/peerreview

gets this link:

/Users/rossman/Dropbox/Users.rossman.Documents.miscservice.peerreview

Entry filed under: Uncategorized. Tags: .

Bright light city gonna set my soul on fire Dropbox, Exploiting the Alias vs Symlink Distinction

4 Comments

  • 1. Gabi Huiber  |  January 12, 2011 at 10:43 am

    I love Dropbox. It has restored sanity to sharing files for small projects with distributed teams. Left to their own devices, management consultants will e-mail all this crap back and forth, with ad-hoc naming conventions and all the assorted hassle. They can’t be bothered with SVN, but will fall for Dropbox easily. It’s wonderful.

    However, for high-volume online backup and for syncing user home environments across multiple computers, I use SpiderOak, precisely in order to avoid the gymnastics you mention. My neighbor recommended it. It works across all the OS’s in our house, and I only need one account. I have seen reviews that complain about its resource needs, but I’m very happy with it.

    • 2. Michael Bishop  |  January 12, 2011 at 1:34 pm

      Hi Gabi, I’m a Dropbox user, curious what (if anything) Dropbox does better than SpiderOak.

      • 3. Gabi Huiber  |  January 12, 2011 at 9:57 pm

        Dropbox doesn’t do anything better than SpiderOak. It does less but (maybe therefore) it’s easier to use. For the sharing and backup needs that you can meet with the free 2G, Dropbox wins.

  • […] I described how I started using Dropbox by keeping my file system as is and adding symbolic links to ~/Dropbox. (As described in that post, this is a good strategy if you mostly use one computer but a bad idea […]


The Culture Geeks


%d bloggers like this: