Everyone loves Dropbox for the simple and instant syncing of files between their devices but as anyone who runs their own website or blog knows it can often be a pain to get files to and from your servers… Dropbox is made to solve this problem, it just takes a little coaxing.

In this tutorial we are going to bring the simplicity of Dropbox to your server by selectively syncing your files, make those files accessible anywhere and your life easier.

Begin

This tutorial assumes you are using Ubuntu on your server it may work on other distributions with small tweaks. I run simple servers on Amazon EC2 and Linode, if you are just getting started start there.

I’m going to go a little fast with the steps here, my main goal is to get all this information together so the next person doesn’t need to search half of the internet to find it like I did.

Step 1: Go into your local Dropbox folder and create a folder called Server, or whatever you’d like but if it’s different you’ll need to remember that later.

Install Dropbox

Step 2: Next, get a command line session with your server via SSH. Then let’s check if you are on 32 or 64 bit.

uname -m {% endsyntax —

If it says x86_64:

cd ~ && wget -O - “http://www.dropbox.com/download ?plat=lnx.x86_64” | tar xzf - {% endsyntax —

If it says i686:

cd ~ && wget -O - “http://www.dropbox.com/download ?plat=lnx.x86” | tar xzf - {% endsyntax —

Step 3: Let’s download a nice python script to help us manage Dropbox. And a bash script that we’ll use to start and stop Dropbox.

mkdir ~/utils wget -O ~/utils/dropbox.py “http://www.dropbox.com/ download?dl=packages/dropbox.py” chmod 755 ~/utils/dropbox.py wget -O ~/utils/dropbox_temp “https://raw.github.com/ gist/2347727/108fc8af551cb4fdf7cdd08b891a45f405d283dc/dropbox” {% endsyntax —

Step 4: Run the Dropbox daemon from the newly created .dropbox-dist folder.

~/.dropbox-dist/dropboxd {% endsyntax — Step 5: Dropboxd will tell you “This client is not linked to any account…” and give you a link copy that and paste it in your local web browser, authenticate and validate the new connection.

Step 6: Once Dropbox is connected kill the daemon with a Ctrl-C.

Now that Dropbox is linked let’s install it as a service in Ubuntu.

Step 7: First, edit the script and replace “user1 user2” with your server username not your Dropbox account. Then we’ll move it to the right place, set the proper permissions and have it start on boot.

nano ~/utils/dropbox_temp sudo mv ~/utils/dropbox_temp /etc/init.d/dropbox sudo chmod +x /etc/init.d/dropbox sudo update-rc.d dropbox defaults {% endsyntax —

Check if Dropbox is running, if it’s not start it.

sudo service dropbox status sudo service dropbox start {% endsyntax —

It’s Alive

~/utils/dropbox.py status -> Downloading 3,134 files (0.1 KB/sec, a long time left. Grab a Snickers) {% endsyntax —

Ahhh! Basically right now Dropbox is syncing your entire Dropbox to your server, for me that’s not good so let’s pare it down using selective syncing.

Selective Sync

Step 8: You will need to call the ‘exclude add’ command for each top level folder you don’t want to sync, I’d suggest starting by excluding your biggest folder to save Dropbox and your server some work.

cd ~/Dropbox ~/utils/dropbox.py ls -> Photos Projects Public Server Work

~/utils/dropbox.py exclude add Projects ~/utils/dropbox.py exclude add Photos ~/utils/dropbox.py exclude add Public ~/utils/dropbox.py exclude add Work ~/utils/dropbox.py ls -> Server {% endsyntax —

Success?

Go to the Dropbox folder in your server home directory, create a file in it and let’s test it out.

cd ~/Dropbox/Server echo ‘success’ > success.txt {% endsyntax —

Check your Dropbox folder on your local machine, if success.txt just showed up you are connected!

Success!

The folder works both ways, make edits, add a new file and you’ll see it on your server nearly instantly.

-Ben