Dropbox and symlinks

In short: The Dropbox server does not support symlinks. All your local symlinks are followed and uploaded as plain files and folders into your Dropbox account.

No symlinks in the server

In order to support old Windows machines that do not have symlinks, the Dropbox team decided to cut symlink support from all platforms.

Unfortunately this is a design decision that we made a very long time ago. There is no notion of symlinks in the Dropbox system (Windows XP didn't support symlinks) so our solution was to sync all the data within symlinks as if they were actual folders anyway. — Rian H., Dropbox employee

The fact is: the Dropbox server has no support for symlinks, it only syncs files and folders.

Just browse your files in the Dropbox website and see it for yourself: all your symlinks were converted to plain files and folders.

Local symlinks are followed

When you create a symlink inside your Dropbox folder in your computer, the syncing process will start. But instead of uploading the symlink itself, Dropbox will follow the symlink and will upload the file or folder it points to.

It doesn't matter if your symlink points to a file that's inside or outside your Dropbox folder. Symlinks are always followed and Dropbox always treat your symlinks as if they were plain files or folders.

This is the default behavior and cannot be changed.

External symlinks

Since symlinks are always followed, it's a common practice to use them to include external folders into your Dropbox without actually moving them there.

To include your Desktop folder into Dropbox, just make the ~/Dropbox/Desktop symlink pointing to ~/Desktop.

$ ln -s ~/Desktop ~/Dropbox/Desktop

Note that this practice will become obsolete when (if?) the #1 feature request Watch Any Folder is implemented.

Internal symlinks

Internal symlinks are complicated. Expect problems. Avoid if possible.

When both the symlink and the target file reside inside your Dropbox folder, you end up with duplicated and possibly unsynchronized content.

Duplicated files and your quota

Say you just made the symlink ~/Dropbox/mp3 pointing to your 5GB music collection folder in ~/Dropbox/iTunes/iTunes Media/Music/. When syncing, Dropbox will follow the symlink and will upload it as a plain folder. Guess what? There goes all your music duplicated to the new mp3 folder in your Dropbox account.

Dropbox is smart enough to detect that those files were already uploaded, so it will do a server-side copy and will not spend your bandwidth uploading them again. But regardless, those "new" files will eat up your account quota: now your music spends 10GB of quota.

Note: Mac users who upgraded to iPhoto '11, which uses symlinks in the photo library, saw their Dropbox free space disappear as their photo collection got duplicated. Fortunately, there's a fix.

To avoid the quota disaster, you can use a hack to ignore the symlinks that point to huge folders. Or just avoid symlinks at all, if possible.

Symlink here, folder there

$ cd ~/Dropbox
$ mkdir foo
$ touch foo/abc.txt
$ ln -s foo bar

After Dropbox syncing:

The symlink is always preserved in the original computer it was created. But in any other instance it will be a plain folder: the Dropbox website and mobile app, a new computer you install Dropbox. This discrepancy between the main machine and the server can lead to unexpected problems.

The symlink in the original computer is also the only thing that keeps both folders connected. If you change only one of the folders in the web interface, when the original computer syncs it will replicate the change to the other folder. If you format that computer, the connection is gone and each folder is now really independent of each other. They will become unsynchronized.

Only remove symlinks in main computer

Never remove, via web or mobile interface, a folder that's in fact a symlink in the original computer. Both the symlink and the original folder contents will be removed.

In the previous example, say you remove the bar folder in the web interface. It works, but when your original computer syncs this change, bad things happen. As you expect, the symlink bar will be removed from your computer. As you do not expect, the original folder foo is now empty!

How it happens: The procedure to remove folders is to first remove all the folder contents (files and subfolders) and then remove the empty folder. Since the Dropbox client needs to remove the "folder" bar from your computer, that's what it does. But here bar is a symlink to foo, the original folder, which sadly get all its contents removed. When it's empty, Dropbox finally removes bar.

Not a backup utility

Note that Dropbox is not a backup utility, but a file synchronization utility. We made the decision to handle symlinks transparently, so that the complete file tree would be exactly the same on all operating systems and on our servers, as presented by the file managers. — N.N., Dropbox forums moderator

Since symlinks are not preserved, avoid using Dropbox as a backup utility. All your symlinks will be lost in a restore. You'll have to manually recreate them.

Restoring the symlinks

If you install Dropbox in a new machine, you will have to manually recreate all the symlinks.

  1. Wait for the initial download to complete.
  2. Quit Dropbox.
  3. Find the symlink location and remove the duplicated file or folder.
  4. Recreate the symlink to the original file or folder.
  5. Repeat steps 3 and 4 for each symlink that need to be restored.
  6. Launch Dropbox.

Keep a list of your symlinks

It's a good practice to keep an updated list of all your symlinks, so you can restore them manually in a new computer, if needed.

$ find ~/Dropbox -type l -ls > ~/Dropbox/symlinks.txt

Avoid symlinks if you can

Given all these gotchas, it's better to avoid using symlinks inside your Dropbox folder until they add real support for them in the server.


Use your Votebox credits to tell Dropbox you want symlink support: https://www.dropbox.com/votebox/350/preserve-implement-symlink-behaviour

— EOF —