Getting around Dropbox’s symlink limitations on Linux

Getting around Dropbox’s symlink limitations on Linux

As of mid-2019, Dropbox announced that they no longer support symlinks that point outside of the main Dropbox folder. In this tutorial, we show a workaround on Linux that enables us to store in Dropbox any file, even if it is not located within the main Dropbox folder.

What is the limitation and why it’s a problem?

Imagine that you have a bunch of files that you would like to synchronize across your devices, but they are stored outside of your Dropbox folder. For example, assume that your main Dropbox folder is located at ~/Dropbox but your documents live in the ~/Documents folder. Up to recently, you had the option to add those files in Dropbox without physically moving them by creating a symlink:

1
ln -s ~/Documents ~/Dropbox/Documents

Unfortunately this feature got deprecated by Dropbox. Every folder/file that was a symlink is now copied and the “(Symlink Backup Copy)” is appended to it. This means that any changes you make to your original external folders will no longer be visible to Dropbox.

Working around the limitation using mount

Thankfully there is a quick and easy solution to work around the limitation on Linux. Below I explain how this can be achieved on Ubuntu, but the process should be similar to other Linux distributions.

To achieve the same effect, we are going to use “bind mount”. A bind mount enables us to create an alternative view of the original directory tree in a new location. Any modification on one side is immediately reflected on the other, effectively allowing us to share the same data.

To create a bind mount you can use the following commands:

1
2
3
4
5
# Create mounting point in Dropbox folder
mkdir -p ~/Dropbox/Documents
# Link the external folder in Dropbox
sudo mount --bind ~/Documents ~/Dropbox/Documents

That’s it! Dropbox should be able to start synchronizing the data. Unfortunately the mount command does not persist between restarts. To make the change permanent we need to modify the /etc/fstab file by appending:

 

WARNING: Editing your fstab file incorrectly can render your computer unbootable. It’s straightforward to recover from this problem but before editing the file, you are advised to do some reading.

# Add one line for every external Dropbox folder
/home/YOUR_USERNAME_HERE/Documents
/home/YOUR_USERNAME_HERE/Dropbox/Documents none
defaults,bind,x-gvfs-hide 0 0

Note that adding the x-gvfs-hide option will allow make Nautilus file manager to hide the mounting points.

This article has been published from the source link without modificaations to the text. Only the headline has been changed.

Source link