Syncing files via Dropbox to a linux server

Posted on

Running scripts against plain-text notes from an iPhone requires a server. The iPhone app Shortcuts allows you to run arbitrary code via SSH — a perfect solution for my notes and todo lists, which are synced between my phone and laptops with Dropbox. I just needed those files somewhere I could SSH into.

I keep a Linux server running, so the remaining problem was getting Dropbox to sync a specific folder to it. Here’s how.

Note: This post was written in 2020 against Ubuntu 18.04. The core steps still work, but Dropbox’s headless Linux support has become less reliable on newer systems – authentication in particular changed in late 2020 and can fail silently on Ubuntu 22.04+. If you’re setting this up fresh, Maestral is a well-maintained open-source Dropbox client with first-class headless support and a cleaner auth flow. If you’re evaluating Obsidian as an alternative sync layer: Obsidian’s official CLI (v1.12+) requires a running desktop app and does not work in a true headless environment.

First you need to install some extra dependencies 1 which are required by the Dropbox install script.

1
sudo apt-get install libc6 libxxf86vm1 libglapi-mesa libxdamage1 libxfixes3 libxcb-glx0 libxcb-dri2-0 libxcb-dri3-0 libxcb-present0 libxcb-sync1 libxshmfence1

Grab the correct version of the install script from https://www.dropbox.com/install-linux

I am running Ubuntu 18.04 x64 so the install commands look like so.

1
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf

That will download the install script and run it. We can then start running the Dropbox daemon. The first time we run this, it will prompt us to authorise ourselves by following a link in the browser. After doing so, it may appear to hang, but the daemon is just running in the foreground. You can ctrl-c to get out of it.

1
~/.dropbox-dist/dropboxd

We then want to download the python script which Dropbox provides to control the service. The following will download it to your home directory.

1
cd ~ && wget -O ./dropbox.py https://www.dropbox.com/download?dl=packages/dropbox.py

We can then use the script to setup the Dropbox service to autostart.

1
./dropbox.py autostart

And then actually start it in the background.

1
./dropbox.py start

If you are like me, you probably don’t want your entire Dropbox folder syncing to your server, so you can do the following. This will exclude the content of the Dropbox folder from syncing, and then specifically allow a certain folder. In this case some_folder_you_specifically_want_to_sync.

1
2
./dropbox.py exclude add ~/Dropbox
./dropbox.py exclude remove ~/Dropbox/some_folder_you_specifically_want_to_sync

You now have a specific folder syncing to your Linux server with Dropbox.