Dropbox on Ubuntu server

It turned out to be a small Google challenge to find a working method for running the Dropbox daemon on an Ubuntu 15.04 server as systemd service. Some sites propose to schedule the dropboxd as cron job. Other sites propose an Upstart script, which was abandoned by Ubuntu this year and replaced by systemd. Then there is the proposed solution to add a script as /etc/init.d/dropbox, which does appear to work at first and then exits at random. Potatoes. Potatos. After the break what I found to be the solution.

As superuser, create the file /etc/systemd/system/dropbox@.service with the following content:

[Unit]
Description=Dropbox agent for %I
After=local-fs.target network.target

[Service]
Type=simple
User=%I
Group=owners
ExecStart=/opt/dropbox/dropboxd
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=5
TimeoutSec=300
[Install]
WantedBy=multi-user.target

It is assumed that the Dropbox headless daemon has been installed in the /opt/dropbox directory and configured of user radko. The service is started during boot after issueing the following command:

sudo systemctl enable dropbox@radko.service

The service can be manually started and its status can be queried:

sudo systemctl start dropbox@radko.service
service dropbox@radko status

dropboxNote that this manually started service is killed on logoff. A reboot is really needed to make the service persistent.

Four tests to pass:

  1. The service should continue to run in the background. Log out from the server and log in again.
  2. The service should be started automatically during boot. Reboot the server.
  3. The service should run stable. Monitor the status of the service.
  4. The service should work. Drop files in the Dropbox folder and verify it is synced.

That’s all for now. Let’s see what other aspects of the systemd service can be tweaked.

Update November 22nd 2015: The systemd service described above will fail when the user has an Encrypted Home directory. Check the logging data of the dropboxd service with the following command:

journalctl -e -u dropbox@radko.service