Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use symbolic links in a Dropbox folder Apps
If you use Dropbox, you can place symbolic links in your Dropbox folder. This is a great way to backup directories while maintaining the local file structure you desire. As a bonus, the green checkmarks won't display on items backed up in this manner, though they will show up on other computers.

To create a symbolic link, open Terminal, and cd into your Dropbox folder. Then run a command like this. This command would add a symbolic link for a folder called Test that is in your Documents folder:
ln -s ~/Documents/Test
Using symbolic links allows you to add items to your Dropbox folder yet leave them in their "correct" location. So you could, for example, put your entire Documents folder in your Dropbox folder - if you have enough space - yet leave it in its standard location in your home folder.

Also, if you want to back up, say, your Documents folder to Dropbox in this manner, the backup won't take up any extra physical space in the Dropbox folder on your Mac.
    •    
  • Currently 4.33 / 5
  You rated: 3 / 5 (9 votes cast)
 
[54,765 views]  

Use symbolic links in a Dropbox folder | 20 comments | Create New Account
Click here to return to the 'Use symbolic links in a Dropbox folder ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use symbolic links in a Dropbox folder
Authored by: e_whizz on Aug 15, '12 07:43:08AM
"Also, if you want to back up, say, your Documents folder to Dropbox in this manner, the backup won't take up any extra physical space in the Dropbox folder on your Mac."
This last sentence is a little misleading. It still does count towards your DropBox quota.

[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: kirkmc on Aug 15, '12 10:44:04AM

Right, but it won't use up space on your Mac. If you have, for example, a laptop with an SSD, and your Documents folder is 50 GB, adding a symlink to your Dropbox folder won't use another 50 GB on your SSD. (It will, of course, count against your Dropbox quota.)

---
Mac OS X Hints editor - Macworld senior contributor
http://www.mcelhearn.com



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: DavidRavenMoon on Aug 19, '12 08:11:30AM

It wasn't misleading to me. He said "on your Mac", not on the DropBox server.

This is exactly why I haven't been using DropBox. I don't need it for sharing, and have been wanting to use it for backups, but didn't want to have the same files in two places on my Mac.

---
iMac 2.93 GHz Core 2 Duo, 8GB, 1TB, Mac OS X 10.8
www.david-schwab.com
www.myspace/davidschwab
www.sgd-lutherie.com



[ Reply to This | # ]
Link behavior
Authored by: lullabud on Aug 15, '12 08:16:24AM

I use links extensively with dropbox. They are very useful, but it's important to understand how they work.

Symlinks will work exactly like you had copied the folder into your dropbox. If you modify a file, such as edit the exif or id3 data, it will be modified on all computers. This means that if you share a folder via symlink with somebody, and they delete those files, they delete *your* files. Beware of that. This option is best used for synchronization across computers, not sharing.

Hard links, however, do not function this way, and still save disk space. If you hard link a file into dropbox, whenever it is edited in its dropbox location by any computer, that link is broken and the original file stays the same. If the dropbox versions are deleted, the original hard linked copy stays on the disk. This makes hard links much more useful for sharing, but not useful for synchronization across computers. Unfortunately you can't hard-link a folder, so you have to resort to things like gnu cp or rsync --link-dest to make a tree of hard linked files.


And remember the safety net that dropbox provides. Don't be scared to try it out, you can go back within the last 30 days and download your old versions from your dropbox history if something goes wrong. :)



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: patashnik on Aug 15, '12 08:36:46AM

One Dropbox functionality that breaks, at least for me, is that the "Dropbox" contextual menu in Finder doesn't appear when right-clicking on symlinked files, or files in a symlinked directory.



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: Interactive on Aug 15, '12 09:06:14AM
Would anybody mind explaining the difference between Symlink and Hard Link? If I create an alias on Dropbox of a folder from within my Documents folder, am I creating a symlink or a hard link to the original folder on my Mac?

[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: Sesquipedalian on Aug 15, '12 10:29:09AM

http://en.wikipedia.org/wiki/Hard_link
http://en.wikipedia.org/wiki/Symbolic_link
http://en.wikipedia.org/wiki/Alias_(Mac_OS)

Basically, with a hard link, the same file data exists in two places at once. So ~/Documents/myfile.txt and ~/Dropbox/myfile.txt are both names for the same data; editing ~/Documents/myfile.txt will instantly change the data in ~/Dropbox/myfile.txt too, because it is the same data. Hard links work perfectly 100% of the time for all operations, even if you move or rename files, but can only be used within a single filesystem (you can't make a hard link to a file on another disk), and cannot be used for folders.

A symlink is a small file that redirects to another file or folder. When you try to open/copy/delete/whatever a symlink, your actions simply get sent to the path that the symlink points to and applied to whatever is found there. Symlinks can point to files and folders, can point to items on other disks, and work for almost all operations. But they are pretty dumb; if you move or rename the file that the symlink points to, the symlink will be broken, because it now points to nothing.

An alias is a pointer (like a symlink). It is able to point to files, folders, other computers on network, and more. An alias is usually able to find its target even if the target moves or is renamed, which makes aliases much more robust than symlinks. However, aliases are Mac specific (they were invented for use by the Finder) and don't usually work with low-level operations (e.g. UNIX command line programs).

Dropbox uses various low-level operations to do its magic, and so it can't follow aliases. Putting an alias file into your Dropbox folder will result only in the alias file itself getting uploaded to Dropbox.

[ Reply to This | # ]

Use symbolic links in a Dropbox folder
Authored by: Interactive on Aug 15, '12 11:28:39AM
Thank you, Sesquipedalian, for taking the time to explain the difference. Your explanation is clearer than the general information found at other places, particularly with aliases in OS X.

I created a folder on Dropbox that contains (1) an Excel spreadsheet that keeps track of my students' grades and (2) other course-related folders and files. Then, on my home Mac and on my work Mac, I created an alias on the Desktop that points to the folder on Dropbox.

This way, if I changed data in the spreadsheet, for example, while at work, then when I return home and access the spreadsheet from the folder alias on the Desktop, the updated spreadsheet is there. That is, the originals always reside on Dropbox.

This use of aliases is the reverse of what you warned me about in your last paragraph. But, this is OK, isn't it? Or, does it have a potential for issues?

[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: leamanc on Aug 15, '12 08:53:33PM

The alias will only work on the Mac you created the alias on. On another computer linked to your Dropbox account, the alias file will copy to your Dropbox, but will be useless.

Symlinks are covered in the Dropbox documentation as the way to achieve what we're talking about here. While this hint is great and very well written, I would recommend that everyone who is interested in working with symlinks and Dropbox to just check out the Dropbox documentation.

[ Reply to This | # ]

Use symbolic links in a Dropbox folder
Authored by: leichter on Aug 19, '12 11:31:52AM

There's a subtle point that, once you understand it, makes symlinks much more useful in Dropbox.

The whole design of symlinks in Unix tries to make them invisible to programs that don't specifically try to manipulate them. So suppose 'sym' is a symlink to 'file'. If a program opens 'sym' for read, it actually gets the data in 'file'. If it appends to 'sym', it actually appends to 'file'. However, if it deletes 'sym', what disappears is the link 'sym', not the file 'file'. Opening 'sym' for writing as a new file - not appending to it - is equivalent to deleting the old file and creating a new one: It leaves 'file' unchanged and creates an entirely new file named 'sym' which no longer has any connection with 'file'.

A link to a directory follows the same rules. Looking a file up using the symlink as the name really searches the linked-to directory. Creating a file through the symlink is like appending: It creates the entry in the linked directory. And so on.

A program that wishes to do something special - like change where a symlink points - has to be aware that it's dealing with a symlink and use special OS calls for that exact purpose.

Dropbox works with symlinks *but it doesn't do anything special with them*. So suppose you put that 'sym' linked to 'file' in your Dropbox directory. Dropbox comes along, finds a new file, and sends it to its servers. What does it send? Well, first the name 'sym', and then the "contents" - i.e., what it gets from reading 'sym' which is exactly the contents of 'file'. On the server, and then later on other clients, what you will find is a normal file named 'sym' with the contents of 'file'. *There is no connection with a file named 'file'.* If you change 'file' on the system where 'sym' links to it, the changes propagate. If you change it anywhere else, the changes propagate back - but Dropbox doesn't modify files in place, it writes entire new ones. So the effect back on the original system is to break the link and write a new file named 'sym' with the latest contents - but no connection to 'file'.

I know of no way to keep a link to a *file* as a symlink across updates. But the story is different for *directories*. Unlike ordinary files, directories are normally updated in place (unless you explicit delete and recreate them). So you can do the following:

1. Create directory 'dir' anywhere you like.
2. Create symlink 'dirlink' pointing to 'dir' in your Dropbox folder.
3. Wait for 'dirlink' to appear on all other clients. It will appear as an ordinary directory, not as a symlink. If the original 'dir' had files in it, those will now appear as files on the clients, too.
4. On each client, rename 'dirlink' to 'dir' *in the place you want it to appear in your directory tree*. (Renaming only works if you are staying not the same device. Otherwise, you need to create 'dir' and move all the files.) This need not be the same on all clients, though it's easier to keep track of if it is.
5. On each client, create symlink 'dirlink' pointing to 'dir'.

Now you have a 'dirlink' on each client, which will to Dropbox look like a subdirectory - and it will sync all the files in that "subdirectory". Changes made on any client to any file in 'dir' aka 'dirlink' will be synced to all the other clients as well. Files created or deleted in 'dir' will be created/deleted on every other client as well.

It's probably easiest to do all this while there are no files in 'dir'. Otherwise, Dropbox sometimes repeatedly syncs the same files until everything eventually settles down.

The limitations here:
- Some platforms (e.g., iOS) don't support symlinks. To them, 'dirlink' will just be an ordinary subdirectory.
- Any time you add a new client, you have to go through the process for that client. Certain reset operations in Dropbox - anything that requires re-syncing every file in the Dropbox folder on a client - will require the same, because Dropbox doesn't know how to *create* symlinks - it'll just create an ordinary subdirectories.

I've used this configuration for a couple of years. You have to watch out for the reset situations and such, but generally once you have it set up, it "just works".

---
-- Jerry



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: friedmaj on Aug 15, '12 10:41:43AM

I have been using symlinks in Dropbox for several months, and the Dropbox contextual Finder menu works - but occasionally (twice I think) it has disappeared. It returns with a re-installation of the Dropbox app.



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: fahirsch on Aug 15, '12 11:16:03AM

For those that are Teminal impaired: SymbolicLinker (http://www.macupdate.com/app/mac/10433/symboliclinker) is a Contextual Menu/Service to create symbolic links.
I have been using symlinks to group folders in a SL server without any problems (I am aware that the DropBox backup does not preserve permissions, but it's not a problem in my case),

Edited on Aug 15, '12 11:16:33AM by fahirsch



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: gkurtz1 on Aug 15, '12 03:00:32PM

It's worth noting that when you add a sym link inside the Dropbox folder, Dropbox follows the sym link and syncs the data it points to, meaning that on the Dropbox servers, and on any other linked computers, that data exists as actual files, not as a sym link.

For this reason, it's actually generally better to put the actual data in the Dropbox folder in the first place, and put sym links in the original locations outside the Dropbox folder.



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: frank_martin on Aug 16, '12 08:34:04AM

Whoa! So if I follow the original hint, I end up with duplicate data? Then that is no good for syncing data between computers, right?



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: morespace54 on Aug 17, '12 11:22:15AM
Whoa! So if I follow the original hint, I end up with duplicate data? Then that is no good for syncing data between computers, right?
No, not on your "original" computer you don't have duplicates, therefore this hint. Let's put it this way:

Mac 1: Your original file is outside of your Dropbox folder, with a symlink inside your Dropbox folder (1 copy).

Dropbox servers: a copy of your original file from your original folder (because you've put a symlink in your Dropbox folder on your Mac 1).

Mac 2, 3, etc.: a copy of your original file from your original folder (1 copy) on each Macs.

But as mentioned earlier, if you make changes on your file from your Mac 2 or 3, the changes will be reflected on the Dropbox servers and than on your original file which reside on your original folder on your original Mac (thanks to the symlink in your original Dropbox folder).

Hope it makes sense.

[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: frank_martin on Aug 17, '12 12:41:40PM
...it's actually generally better to put the actual data in the Dropbox folder in the first place, and put sym links in the original locations outside the Dropbox folder.
Can I "merge" Desktop folders on two Macs this way? Or two Documents folders? In other words, in the Dropbox folder, create a folder called "Dropbox Desktop" and put all the data from both Desktop folders on the Macs in the Dropbox Desktop folder, then replace the Desktop folders in the home directories with symlinks named "Desktop" pointing to "Dropbox Desktop" in the Dropbox folder?

[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: frank_martin on Aug 17, '12 01:46:23PM

I tried this, and it worked. Both computers running 10.6.8. On one computer, the OS wouldn't let me move the original Desktop folder to the trash or out of the home folder, which I needed to do to replace it with the symlink, so I logged in as root to get that done. Upon logging back in as a the regular user, Viola! I have the same desktop on both computers. I am stunned.

The Finder window sidebar shows the name of the folder in Dropbox ("Dropbox Desktop",) not the name of the symlink ("Desktop"). That is probably a good thing, to remind me of the setup. But if I changed the Dropbox folder name to desktop, I could have a "transparent" set up.

The Desktop still works as expected of Dropbox isn't running, but of course sync doesn't take place.

Aliases placed on one desktop appear on the other desktop, but don't work.

I'd recommend a solid backup of everything before attempting this.

I have senior clients with multiple homes who may like this setup. They cannot really deal with any complexity at all: this gives them the illusion of having single desktop appear on multiple computers.



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: JMoVS on Aug 16, '12 01:17:00AM

For easier creation of symlinks, you can add this script http://cl.ly/ImZ5 to "User/Library/Services" and right click on finder items to create these.



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: OsamaS on Aug 16, '12 12:18:19PM

Using the symbolic link trick works for me if my source folder is on my HD. If the source folder is on my NAS all it does is that just create the subdirectories but not actually copying any files.
Any idea what's going on? Anyone got it working correctly with network shares?
thanks
OsamaS



[ Reply to This | # ]
Use symbolic links in a Dropbox folder
Authored by: robleach on Aug 23, '14 02:54:59PM

I see this thread is old, but I have a question for anyone who knows... Regarding the comment that "dropbox respects symbolic links", if you create a symbolic link from one dropbox directory to another dropbox directory, will changes made to files in one of the locations via an editor on your phone cause the files in the other location to also have those changes *if* your drop-box synced computer is *off*? I.e. is it only your computer that keeps symlinked folders synced or does dropbox do it too?



[ Reply to This | # ]