Share the Knowledge!

This guide is designed for VPS owners who use CentOS 32-bit, or 64-bit.

Prerequisites

  • Architecture x86 (32-bit) or x86_64 (64-bit)
  • wget
  • vi (text editor)
  • Python 2.x
  • a web browser (on a PC you have access to)

Setup process

Install the latest dropbox linux distro

This ONLY installs for the current user. I would recommend root. But you are free to choose whatever user you want to have the dropbox user on the VPS.

  1. Check the version of CentOS you have:
    uname -m
  2. If you are on 32-bit CentOS: (i686)
    cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
  3. If you are on 64-bit CentOS: (x86_64)
    cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Run & Link your Dropbox Account

  1. Run the dropboxd application.
    ~/.dropbox-dist/dropboxd
  2. It will return repeatedly:
    "This computer isn't linked to any Dropbox account...
    Please visit https://www.dropbox.com/cli_link?host_id=(some code)" to link this device.
  3. Go to a browser window. (Doesn’t matter if it’s the same computer, can be your Windows PC.) Copy the link, paste it, and log into the dropbox account you want the account to be linked to.
  4. After your done logging in, a new folder will appear on the server’s user directory called “Dropbox”. Use ctrl+c to stop dropboxd for the next step.

Downloading the CLI interface from Dropbox

  1. If you do not have python (2.x) installed, you can do so with:
    yum install python
  2. Type the following to download & install the official dropbox.py script:
    mkdir -p ~/bin && wget -O ~/bin/dropbox.py "https://www.dropbox.com/download?dl=packages/dropbox.py" && chmod +x ~/bin/dropbox.py
  3. First you need to turn on dropbox:
    ~/bin/dropbox.py start
  4. If this is a server, you want to prevent lan broadcasting so you don’t get in trouble with your VPS provider:
    ~/bin/dropbox.py lansync n
  5. From here, you have to wait.. you can type this to see when dropbox is finished synchronizing all the data.
    ~/bin/dropbox.py status
    "Up to date"
  6. The steps below explain how to sync a specific folder(s), if you dont care about this, you can go straight to step 10. Before moving to the next step, it is important to know that putting files in your root directory of dropbox will clutter things, create a folder like “unsorted”, and put your files in there. (Note: Someone could add white list functionality to dropbox.py via github)
  7. After it says it’s up to date, you want to exclude everything:
    cd ~/Dropbox && ~/bin/dropbox.py exclude add *
  8. This will show all the files excluded.
    ~/bin/dropbox.py exclude list
  9. Then you can remove files from exclusion (the ones you want the server to have), by typing this:
    ~/bin/dropbox.py exclude remove 'a folder with spaces' my_homework etc
  10. Give it a few seconds.. then turn off the dropbox sync like this:
    ~/bin/dropbox.py stop

Creating soft links outside of ~/Dropbox

The first argument is the path to the folder you want to sync, like your log files.
The second argument is the path to the new dropbox folder/file you want to keep updated in ~/Dropbox.

  1. Ensure that dropbox is stopped by typing:
    ~/bin/dropbox.py stop
  2. Remove the synced file/folder
    rm -rf ~/Dropbox/my_server_log
    ln -s /path/to/(server log) ~/Dropbox/my_server_log
  3. (Optionally) This may be the /path/to/(server log) might be out of date. You can make dropbox OVERWRITE the server file by setting the date below the last modified date shown on dropbox. I highly recommend that you backup the dropbox folder before you start syncing.
  4. Start dropbox:
    ~/bin/dropbox.py start
  5. You can “watch” the sync by typing this:
    ~/bin/dropbox.py status
  6. When uploading new content, it will say files uploaded, when downloading, it will say files are downloading. When deleting, you don’t get any messages on what’s being deleted using status.
  7. Repeat steps 1-6 until you have soft linked all files/folders you wanted to have synced with ~/Dropbox.

Create a linux service daemon (Automatic sync after reboot)

  1. Ensure that dropbox is not running, by typing this:
    ~/bin/dropbox.py stop
  2. On CentOS, type the following:
    touch /etc/init.d/dropbox && chmod 755 /etc/init.d/dropbox && vi /etc/init.d/dropbox
  3. Press “i” without quotes to enter edit mode. Then paste the following code:
    # chkconfig: 345 85 15
    # description: Startup script for dropbox daemon
    #
    # processname: dropboxd
    # pidfile: /var/run/dropbox.pid
    # config: /etc/sysconfig/dropbox
    #
    
    ### BEGIN INIT INFO
    # Provides: dropboxd
    # Required-Start: $local_fs $network $syslog
    # Required-Stop: $local_fs $syslog
    # Should-Start: $syslog
    # Should-Stop: $network $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start up the Dropbox file syncing daemon
    # Description:       Dropbox is a filesyncing sevice provided by dropbox.com
    #                    This service starts up the dropbox daemon.
    ### END INIT INFO
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # To configure, add line with DROPBOX_USERS="user1 user2" to /etc/sysconfig/dropbox
    # Probably should use a dropbox group in /etc/groups instead.
    
    [ -f /etc/sysconfig/dropbox ] && . /etc/sysconfig/dropbox
    prog=dropboxd
    lockfile=${LOCKFILE-/var/lock/subsys/$prog}
    config=${CONFIG-/etc/sysconfig/dropbox}
    RETVAL=0
    
    start() {
        echo -n $"Starting $prog"
        if [ -z $DROPBOX_USERS ] ; then
            echo -n ": unconfigured: $config"
            echo_failure
            echo
            rm -f ${lockfile} ${pidfile}
            RETURN=6
            return $RETVAL
        fi
        for dbuser in $DROPBOX_USERS; do
            dbuser_home=`cat /etc/passwd | grep "^$dbuser:" | cut -d":" -f6`
            daemon --user $dbuser /bin/sh -c "$dbuser_home/.dropbox-dist/dropboxd&"
        done
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
    }
    
    status() {
        for dbuser in $DROPBOX_USERS; do
            dbpid=`pgrep -u $dbuser dropbox | grep -v grep`
            if [ -z $dbpid ] ; then
                echo "dropboxd for USER $dbuser: not running."
            else
                echo "dropboxd for USER $dbuser: running (pid $dbpid)"
            fi
        done
    }
    
    stop() {
        echo -n $"Stopping $prog"
        for dbuser in $DROPBOX_USERS; do
            dbuser_home=`cat /etc/passwd | grep "^$dbuser:" | cut -d":" -f6`
            killproc $dbuser_home/.dropbox-dist/dropbox
        done
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
    }
    
    # See how we were called.
    case "$1" in
        start)
            start
            ;;
        status)
            status
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            start
            ;;
        *)
            echo $"Usage: $prog {start|status|stop|restart}"
            RETVAL=3
    esac
    exit $RETVAL
  4. Save the pasted contents by pressing escape key, then typing “:wq” without quotes, then press the enter key.
  5. Type this to manually assign which user(s) have dropbox installed:
    vi /etc/sysconfig/dropbox
  6. Typing “i” for edit mode, and then paste this: (“linux_user_name(s)” being the user(s) you are installing with dropbox, example: DROPBOX_USERS=”jdoe”))
    DROPBOX_USERS="linux_user_name(s)"
  7. Save the file by pressing escape key. Then typing “:wq” without quotes, then pressing the enter key.
  8. Then type this to add to chkconfig, and start the newly created dropbox service:
    service dropbox start && chkconfig dropbox on

Curious what version of the dropbox client your running?

Type this:

echo 'Dropbox '`cat ~/.dropbox-dist/VERSION`

Share the Knowledge!

Helpful(19) Unhelpful(1)
  • Dave

    When I get to the step where we run dropboxd and it’s supposed to return a URI, instead I get this:

    > ~/.dropbox-dist/dropboxd
    Unable to access the X Display, is $DISPLAY set properly?

    I don’t have an X server. Any ideas?

    • CookieBin

      dropboxd is a python script written to access the dropbox rpm. I believe your issue has something to do with not having X11 Forwarding. On my PuTTY settings in Connection>SSH>X11. I have X11 forwarding enabled. And the X display location set to localhost:0 with MIT-Magic-Cookie-1

    • Jacques Amar

      The new version of dropbox install on linux uses a GUI that requires X and QT library. You also need to log in with a graphical Xterm remotely instead of a text based one. For those who get that far and their keyboard doesn’t work, it’s a known bug in QT fixable with:

      export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb

  • Kwaku

    Hi, when I run the “~/bin/dropbox.py exclude add *” command, it pauses for awhile like it’s processing then the cursor returns to give me control. But when I check the exclusion/ignore sync list with “~/bin/dropbox.py exclude list” I get “No directories are being ignored.” What could be causing this? Every has worked according to the tutorial till now.

    • Dale Higgs

      Hi Kwaku, I had this error as well. I was able to fix it by residing in the ~/Dropbox directory while executing the command:

      cd ~/Dropbox && ~/bin/dropbox.py exclude add *

      However, it took forever, so I eventually Ctrl+C’d it. Once I did an “exclude list” command, all of my Dropbox folders were in there!

      • Kwaku

        Thanks Dale! It worked! Very grateful

        • CookieBin

          Revision submitted. Thanks Kwaku 🙂

  • Pingback: Dropbox unter CentOS installieren | Chris' Blog()

  • Pingback: DROPBOX on headless CENTOS | linux-tech()

  • Sandro Oliveira

    [root@localhost ~]# systemctl status dropbox.service
    dropbox.service – LSB: Start up the Dropbox file syncing daemon
    Loaded: loaded (/etc/rc.d/init.d/dropbox)
    Active: failed (Result: exit-code) since Qui 2014-08-21 11:56:43 BRT; 36s ago
    Process: 23419 ExecStart=/etc/rc.d/init.d/dropbox start (code=exited, status=203/EXEC)

    Ago 21 11:56:43 localhost.localdomain systemd[1]: Starting LSB: Start up the Dropbox file syncing daemon…
    Ago 21 11:56:43 localhost.localdomain systemd[1]: dropbox.service: control process exited, code=exited status=203
    Ago 21 11:56:43 localhost.localdomain systemd[1]: Failed to start LSB: Start up the Dropbox file syncing daemon.
    Ago 21 11:56:43 localhost.localdomain systemd[1]: Unit dropbox.service entered failed state.

    • pointer2null

      ever find the solution to this?

  • Pingback: How to backup your cPanel accounts to Dropbox | encylia()

  • Pingback: CentOS Linux上安装DropBox全攻略 | sw32技术博客()

  • Brian Craigie

    A few observations:

    You don’t need to wait until it is all synced before excluding folders. Just wait long enough that all your root folders appear (the ones immediately inside the Dropbox folder).

    If after you have excluded all the folders you want, you then add a new folder in dropbox, it will not be excluded – the exclusion list only works on what folders are there at the time you run the exclude command. So, if you only want to sync one folder, say for server backup purposes, I recommend you move all your existing root folders inside a single new folder, call it “main” for example, and then outside the main folder, create your server backup folder. Then simply exclude “main”. Create any new folders inside “main” (the folders you don’t want sitting on your server).

    So your folder structure would look like this:
    DROPBOX -> main -> everything else…

    DROPBOX -> Server_Backups

    Hope that helps. 🙂

  • Centos_Dropbox

    I get to the last step to start the Dropbox service; here is the error:

    dropbox.service – LSB: Start up the Dropbox file syncing daemon
    Loaded: loaded (/etc/rc.d/init.d/dropbox)
    Active: failed (Result: exit-code) since Wed 2014-10-22 13:01:19 CDT; 1min 57s ago
    Process: 6034 ExecStart=/etc/rc.d/init.d/dropbox start (code=exited, status=203/EXEC)

    Oct 22 13:01:19 OMITTED systemd[1]: dropbox.service: control process exited, code=exited status=203
    Oct 22 13:01:19 OMITTED systemd[1]: Failed to start LSB: Start up the Dropbox file syncing daemon.
    Oct 22 13:01:19 OMITTED systemd[1]: Unit dropbox.service entered failed state.

    • Centos_Dropbox

      I’m running Centos 7 x64

      • anonymous coward

        I had to add “#!/bin/sh” to the top of /etc/init.d/dropbox on a recent install of CentOS 7 x64
        I am not sure why but it worked

  • ste

    Dropbox v3 fails in centos — need to use an older version

  • Kwaku

    Hello Guys, I need some help replacing the dropbox account on the CentOS machine with a new one or removing the current dropbox installation and re-installing it with the new account. Thanks in advance.

  • Thaylor Mosquera Castro

    Add a folder to the exclusion list, but I got to eliminate them now want to put another folder with the same name and is impossible, no way to remove that list, to work with those folders

  • Pingback: 实现VPS与dropbox同步 | David博客站()

  • Pingback: Папки сверху. Дропбокс заработал! | at02.ru()

  • in my vps(ubuntu12.04 i386),~/.dropbox-dist/dropboxd don`t run

  • Andrey

    After “Press “i” without quotes to enter edit mode. Then paste the following code:”

    chmod +x /etc/init.d/dropbox
    chkconfig –add dropbox

    chmod 755 /etc/init.d/dropbox

  • Jacques Amar

    Repeating an answer to a question:

    The new version of dropbox install on linux uses a GUI that requires X11, xauth
    and QT library. You also need to log in with a graphical Xterm remotely
    instead of a text based one. For those who get that far and their
    keyboard doesn’t work, it’s a known bug in QT fixable with:

    export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb

    Otherwise awesome article, thanks!

  • Kbrnsr

    If anyone comes here with the problem Sandro Oliveira or pointer2null seemingly have I made a workaround by using systemd instead of sysV.
    If you have added /etc/init.d/dropbox and added via chkconfig you’ll need to remove it:
    chkconfig --del dropbox
    rm /etc/init.d/dropbox

    Create the file /etc/systemd/system/dropbox.service with the following content:

    [Unit]
    Description=Dropbox is a filesyncing sevice provided by dropbox.com. This service starts up the dropbox daemon.
    After=network.target syslog.target

    [Service]
    Environment=LC_ALL=en_US.UTF-8
    Environment=LANG=en_US.UTF-8
    EnvironmentFile=-/etc/sysconfig/dropbox
    ExecStart=/bin/dropbox start
    ExecReload=/bin/dropbox restart
    ExecStop=/bin/dropbox stop
    Type=forking

    [Install]
    WantedBy=multi-user.target

    https://gist.github.com/kbrnsr/3984a0b45dcce5430d01

    • James Fawcett

      This worked perfect for me on Centos 7, i was getting the same errors but now the daemon is happily syncing!

      • Kbrnsr

        No problem duder, if it stops working again I’ll probably update my comment here

    • sing0920

      Thank you for this nice tutorial, it works.

      • Kbrnsr

        No problem duder, if it stops working again I’ll probably update my comment here

    • Juan K

      Thank you, you saved me a lot of work, man! 🙂

  • Loris Albanese

    Thank you very much. This tips work like a charm 😉 (DB running on Centos 7.2.1511)

  • Prakash Khadka

    Here is what I want:

    Create a backup at /Dropbox from cpanel. Then want dropbox.py to automatically sync all data that comes inside /Dropbox to dropbox. After that dropbox.py should remove files/folders which are already sync from /Dropbox. I do not want to stop this dropbox.py daemon. is it already possible ??

  • Eberton Moraes

    Worked, thank you.
    Actually the sinc folder are in /root/Dropbox/
    Bu if i need set the dropbox folder to /home/Dropbox/ how i can do that ?

    • Dex

      you can create a new user in your system.

  • Dex

    Thanks a lot!

  • Wahyudi

    my dropbox status still ‘starting…’ and never changed. and i get “.dropbox” folder (with dot) instead “dropbox”. hope anyone can fix it 🙂