Beware this content is over 4 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.

I’ve been thinking about improving the way I backup my sites and thought I would look into employing Dropbox to help.

While this is by no means a new idea, I thought I would document the process for posterity in the event I need to get this setup again.

First thing you’ll want to do is create a Dropbox account which is very easy and takes only a few seconds. (Full Disclosure: Using the Dropbox link nets me a few more free MBs of storage space if you sign up – which is always much appreciated.)

Once you’re account is up and running, you’ll need to install Dropbox on your Ubuntu server (32-bit and 64-bit).

For a 32-bit Linux Server:

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

For a 64-bit Linux Server:

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

What that should do is download the required archive to your home folder and extract the necessary files to the folder: ~/.dropbox-dist.

If you are logged in as root it should download to /root/.dropbox-dist

Next, run the Dropbox daemon from the newly created ~/.dropbox-dist folder.

1
$ ~/.dropbox-dist/dropboxd

After running that last command you should see something similar to the following:

1
2
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=***[HOST_UNIQUE_ID]***&cl=en_US to link this machine.

In order to authenticate your Dropbox install with the account you created you’ll need to visit that link to complete the link.

N.B. If that daemon is stopped and restarted it shows a different host_id in the URL. Best thing is to leave it running, copy the link in the terminal and visit the link in your browser to complete the linking process.

Once that is complete your terminal on your server should now great you with your Dropbox account name.

1
Client successfully linked, Welcome [NAME]!

After that, you can stop the daemon from running by hitting CTRL + C (or some other key combination) in order to get back control of the command line.

That is the basic install all set and the account your currently logged in with on the server should now have a ‘Dropbox’ folder in their home (~) directory. If you are logged in as root you’ll find it here: /root/Dropbox

Install Dropbox as a Service

For further convenience (and extra credit) you can install Dropbox as a service (credit: Mike Descy).

Firstly you’ll need to create an empty script file.

1
$ sudo vi /etc/init.d/dropbox

Then, paste in the Dropbox script (credit: dropboxwiki.com):

You have to make one change to the file and that is on the second line, set the DROPBOX_USERS variable to your user name, or a space-delimited list of all Dropbox users on your server.

After that change is made, save the script and exit vi.

Next, make the script executable.

1
$ sudo chmod +x /etc/init.d/dropbox

Finally, set up the script to run at boot by adding it to the system start-up.

1
$ sudo update-rc.d dropbox defaults

Note: This script will actually run an instance of the Dropbox daemon under the account of every user specified in the DROPBOX_USERS variable. If you wish to sync multiple users with Dropbox, you will have to go through the steps above for each Dropbox user on your system, prior to running it as a service.

Controlling the Dropbox Service

Now that Dropbox is a service, you can use Ubuntu’s standard commands to manipulate it. First off, you’ll want to start it.

To start the service:

1
$ sudo service dropbox start

When you first start the service, it will attempt to create a “Dropbox” folder in your home (~) directory.

To check the status of the service:

1
$ sudo service dropbox status

To stop the service:

1
$ sudo service dropbox stop

To restart the service:

1
$ sudo service dropbox restart

Reininstall Dropbox

If something went wrong during the install you can try again by deleting all the Dropbox files in the home directory. And start again by downloading the files you need.

1
2
$ cd ~
$ rm -rf .dropbox* Dropbox