27

I have installed Dropbox 2.0.0 via command line on my home server (Ubuntu Server 12.04) to use for off-site automated backups, but I can't change the directory that the Dropbox daemon keeps synced.

I've tried the following:

The official docs say to use the desktop application, which is not applicable in my situation. However I installed the desktop app on my desktop machine and changed the default folder location, but I can't find where this change is stored in the ~/.dropbox/ directory so I can make the same change on the server.

This page (and several others) recommends a Python script to do the job. Looking at the script, it opens a SQLite database called ~/.dropbox/dropbox.db, which does not exist on my Dropbox install, leading me to believe the script is out-of-date.

This forum thread suggests manually inserting the required row in the config.db database, which I did, but it made no difference. I checked the same database file on my desktop machine, and it does not have the dropbox_path key, so I'm presuming the information in that thread is also out of date for version 2.0.

I have tried to launch the Dropbox GUI configuration wizard over SSH with X11 forwarding, as suggested in one of the answers, but the binary must detect the absence of a local X11 install and it starts a command line daemon instead, which provides no means to change the option I need.

I am currently using a symlink, as suggested as an answer, but this is a kludge. I would like to know the correct way to make the change.

How do I change the Dropbox directory on a headless GNU/Linux server?

Update: I've ditched Dropbox and started using Copy. Their Linux tools and support is far superior to Dropbox. I leave this question here in case someone, someday, can answer it.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
x-x
  • 495

9 Answers9

11

So here's my trick:

First I remove all related folder created in my home folder

rm -rf ~/.dropbox-dist

I also remove Dropbox default folder:

rm -rf ~/Dropbox

So then I reinstalled dropbox daemon by define HOME env var like this:

HOME=/data/other_folder dropbox.py start -i

Next, start dropboxd daemon manually by run:

HOME=/data/other_folder /data/other_folder/.dropbox-dist/dropboxd

Then wait it till finish.

ikandars
  • 211
9

You could just create a symlink to ~/Dropbox

ln -s <dir-that-you-want-to-sync> ~/Dropbox
Aditya
  • 504
7

This is a real shortcoming of the Linux application. In the older versions you could modify the settings file. In the most recent version it appears the only solution is to change the $HOME variable before Dropbox starts.

Lets say we want the 'Dropbox' folder to appear in /foo/bar.

  1. Install Dropbox to /foo/bar/.dropbox-dist.
  2. Download the Python script to control Dropbox from the Linux Dropbox page.
  3. In this script, below import os add a line: os.environ["HOME"] = "/foo/bar"
  4. Dropbox controlled / started through the control script now thinks /foo/bar/ is your /home/username/.

This means that when using the control script it now looks for /foo/bar/.dropbox-dist/dropbox to execute the daemon. Configuration files will be written to /foo/bar/.dropbox/. The /foo/bar/Dropbox/ folder will be used for file synchronization.

1

I had the same issue. I wanted to use dropbox to sync a large secondary hard disk on a ubuntu server. What I did was I created a symlink from the secondary hard disk to my home directory before installing dropbox

ln -s /mnt/disks/sdb /home/marc/Dropbox

Only install Dropbox after completing the above step.

This way, the Dropbox in the Home directory is the symlink and the real folder is where ever you symlinked from.

1

My solution is to make a permanent alias named dropb with the HOME-path to your new directory.

echo 'alias dropb="HOME=/media/your/path dropbox"' >> ~/.bash_aliases
source ~/.bash_aliases

Then you can use it like normal dropbox

dropb start -i
dropb status
dropb exclude add ./my_wife/shoe_collection
Raimo
  • 11
  • 1
0

I just hit the same problem and was able to resolve it by

  1. Unlinking the account through the Dropbox web UI:

    https://blogs.dropbox.com/dropbox/2014/10/how-to-unlink-a-device-from-your-dropbox/

  2. Removing the ~/.dropbox directory for the user running dropboxd.

    rm -r ~/.dropbox
    
  3. You might need to clean up the ~/Dropbox directory also.

The first step may be not necessary, but I'd already done that before removing ~/.dropbox, which ultimately allowed me to set it up again.

Remember to cd to the directory you want to be your Dropbox root folder.  It then worked fine for me.

Ben M
  • 1
0

TechRepublic has a page — Set up Dropbox on a GUI-less Linux server — that claims to solve this problem:

… There are GUI tools provided to manage the Dropbox and set it up for [Linux, Windows, and OS X].  But what happens if you want to link a Linux computer that doesn’t have a GUI?  It is possible, with a bit of work, to make Dropbox run without a GUI, allowing you to synchronize files with servers that are running headless or where a user account may not be logged in all the time.

    ︙

To begin:

# mkdir -p /tmp/dropbox
# cd /tmp/dropbox
# curl -OL http://dl.getdropbox.com/u/6995/dbmakefakelib.py
# curl -OL http://dl.dropbox.com/u/637552/Dropbox/dbreadconfig.py
# curl -L -o dropbox.tar.gz http://www.dropbox.com/download?plat=lnx.x86_64

Use plat=lnx.x86 if you want the 32-bit client.  This creates a temporary directory for our Dropbox install files, and downloads two necessary python scripts: dbmakefakelib.py which creates fake stub copies of GUI libraries so the dropboxd daemon starts, and dbreadconfig.py which displays dropbox configuration information.

Decide which user will be running the Dropbox client; this could be a dedicated user or it could be a regular user.  You can also have more than one Dropbox instance running on the system, so you may opt to set it up for multiple users (although each user can only run one Dropbox instance).  For this example, we will have created a special user “dropbox” which will run this Dropbox client.

# su - dropbox
$ cd ~/
$ tar xvzf /tmp/dropbox/dropbox.tar.gz
$ cd .dropbox-dist
$ python /tmp/dropbox/dbmakefakelib.py
dropboxd ran for 15 seconds without quitting - success?

The dbmakefakelib.py script requires gcc, so you must have gcc installed on the system.  This creates fake stub copies of the GUI libraries so that dropboxd will start.  At the end, you can see that it launched dropboxd;  press Ctrl+C to exit the script.  dropboxd should still be running in the background:

$ ps ax | grep dropboxd
24001 pts/0    S      0:00 sh -c { /home/dropbox/.dropbox-dist/dropboxd; } 2>&1

Now that dropbox is running, we need to link it to an existing account:

$ cd ~/
$ python /tmp/dropbox/dbreadconfig.py
host_id = 0bd9c5a15458fbc31f85e892faa7dac4
schema_version = 6

Grab the host_id from above.  Login to the Dropbox web interface, and once you have logged in, manually visit this URL:

https://www.dropbox.com/cli_link?host_id=[HOST_ID]

Replace [HOST_ID] with the host_id that dbreadconfig.py outputs.  When you have done that, the Dropbox site will tell you that you have successfully linked a new computer.  Go to your Account settings and then My Computers and you will see the new computer listed.

If you have not killed the dropboxd process that dbmakefakelib.py started, you will find that it is already downloading the files from the Dropbox to ~/Dropbox/ in the background.

To start the dropboxd daemon in the background at boot, you can add the following to your /etc/rc.d/rc.local init script:

daemon —user dropbox /bin/sh -c "/home/dropbox/.dropbox-dist/dropboxd&"

This will start dropboxd in the background with the privileges of the user for which it is installed (in this case, the user is “dropbox”).  If you want to do a system-wide initscript, visit the Dropbox wiki where there are some examples you can use, including initscripts for Fedora / Red Hat and for Debian / Ubuntu.  It also has examples for how to set up Dropbox running under DJB’s daemontools.

0

If you have ssh access to the machine in question, you might be able to launch the dropbox desktop application on the headless server and have it displayed on your local machine:

  1. Connect to the server using X11 port forwarding

    ssh -Y user@server
    
  2. Now launch the dropbox app, it should appear on your local screen

    ~/.dropbox-dist/dropbox
    

    It may take a while depending on your network connection. Don't give up if you don't get an error message. I can confirm that this worked when I connected from my Debian box to a remote, Ubuntu server that was running no X server. After a few seconds, a second Dropbox icon appeared on my local taskbar and I could access/modify the options of the remote Dropbox install from there.

Now, some details may change since I am using Dropbox 1.6.18 but the basics should be the same. In case the name or location of the app have changed, this is how I found out what command I need to execute to launch the Dropbox desktop app:

  1. Get the list of currently running processes

    top -cbd .10 -n 1 | sort > no_drop.txt
    
  2. Launch the Dropbox app (right click on the Dropbox icon in your taskbar and chose "Preferences...") and repeat

    top -cbd .10 -n 1 | sort > drop.txt
    
  3. Compare the files to find the relevant command

    diff drop.txt no_drop.txt
    
terdon
  • 54,564
0

This might be what you're looking for:

Set up Dropbox on a GUI-less Linux server

I apologize for simply tossing an URL instead of describing the procedures here. I'm at work and can't elaborate more right now. Later I can expand on the answer, I just don't want to lose this valuable URL with your solution.

MestreLion
  • 3,045
  • 4
  • 29
  • 23