21

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.

  • My answer notwithstanding, if this is your home server why don't you just connect a screen to it, make the changes and take the screen away again? – terdon Mar 30 '13 at 2:40
  • @terdon, There is no X11 to run the Dropbox desktop app. – x-x Mar 30 '13 at 2:51
  • Ah, OK, fair enough, try my answer then, it should work. My home headless server actually has X, it is just not started by default and there is no screen attached, that's why I asked. I tested my answer on a real headless, X11-less server though and it worked. X11 forwarding uses the local X server and does not need one to be running on the remote machine. – terdon Mar 30 '13 at 3:02
  • Any better options now that Copy is gone? "Copy was discontinued on May 1, 2016. As a former Copy user, we think you'll like Trove." - tried that? – Xen2050 Oct 24 '18 at 2:55
10

You could just create a symlink to ~/Dropbox

ln -s <dir-that-you-want-to-sync> ~/Dropbox
  • 3
    The question asks, "How can I change the Dropbox directory...", symlinking is not the answer. – x-x Mar 30 '13 at 4:12
  • 4
    But it takes care of the reason for which you want to change the Dropbox directory, cf. XY problem – Aditya Mar 30 '13 at 4:19
  • Actually. I think this won't work, I remember having trouble with symlinks not working with Dropbox. – terdon Mar 30 '13 at 4:26
  • 3
    Symlinking does work, and it's what I was using before asking this question, but it is a Kludge. I came here to find out the correct way to make the change. I will update the question to reflect this. – x-x Mar 30 '13 at 4:37
  • This doesn't work if you need to move your Dropbox folder out of your home directory, e.g. if want other users to be able to access the contents of your Dropbox folder. ikandar's solution below worked for me, for this situation. – jesse.r Jun 28 '18 at 21:17
6

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.

  • 1
    In my experience, you also need to remove ~/.dropbox, or else step 4 will complain about the computer being linked already and won't let you proceed within /data/other_folder. – jesse.r Jun 28 '18 at 21:34
  • Thanks, this worked for me. Caveats: 1. Remember that your data will live in /data/other_folder/Dropbox 2. It will create some other dotfiles inside other_folder, for example when it launches your browser for the initial login. You may try clearing these up later. 3. You must use HOME=... every time you start dropbox. (I tried moving the .dropbox* folders to my real home after everything was working, but that just broke the setup.) – joeytwiddle Nov 6 '18 at 4:53
4

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.

  • Excellent tip! Helped a lot. Pair that with ln -s ~/dropbox.py /usr/local/bin/dropbox for less typing! – Chris McKnight Aug 1 '18 at 1:12
  • This works great for me, though when I attempt to stop dropbox I get a message saying Dropbox isn't responding!. Looks like it does stop though. A bit strange. – ohruunuruus Mar 9 at 19:19
  • Interestingly enough, creating a script in /usr/local/bin that sets HOME before executing the python script (rather than modifying the script itself with os.environ["HOME"]) seems to have cleaned this up. – ohruunuruus Mar 9 at 19:46
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
    
  • 1
    There is no GUI app to forward, only dropboxd, the Dropbox daemon. – x-x Mar 30 '13 at 3:08
  • Did you try the top and diff trick I suggested? Launch the app on your local machine, something must be launched, therefore there is a command. If, in the new version, the only command is the daemon, then launch the daemon, it will still appear on your taskbar. – terdon Mar 30 '13 at 3:11
  • On my desktop machine, running ~/dropbox-dist/dropbox launches a GUI configuration wizard. On the server, through the ssh connection with X11 forwarding on, ~/dropbox-dist/dropbox launches a daemon which instructs me to go to a specific URL to 'link this machine'. Both the server and the desktop are using the exact same archive to install the dropbox files. In the archive the only two executable files are dropbox, and dropboxd, the later is just a shell script to set LD_LIBRARY_PATH and launch the former. – x-x Mar 30 '13 at 3:22
  • Hmm, my remote server has been linked. If I remember correctly, I had to launch a graphical browser (lynx couldn't do it) on the remote machine (always using X11 forwarding) and link the machine using that browser. Try doing that and then launching ~/dropbox-dist/dropbox again. At least we have confirmed it works, the daemon you mention is graphical and is displayed on your local screen right? Therefore, once you have linked your server to your account, you should be able to configure it as described in my answer. – terdon Mar 30 '13 at 3:26
  • It was linked, I just deleted the configuration from ~/.dropbox to start from scratch. "the daemon you mention is graphical and is displayed on your local screen right?" No, it is not graphical when run on the server. It must be detecting the absence of X11 and going into command line only mode, despite X11 forwarding being on. – x-x Mar 30 '13 at 3:37
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.

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

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.

  • Hi, and welcome to SuperUser. Can you elaborate on your answer? Specifically, give a more in depth run down on what the user needs to do? – Service Manager Mar 13 '17 at 20:14
0

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.