buildcontext

Simplify your server using Dropbox, Selective Sync

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

If it says x86_64:

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

If it says i686:

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

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"

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

~/.dropbox-dist/dropboxd

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

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

sudo service dropbox status
sudo service dropbox start

It's Alive

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

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

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

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

blog comments powered by Disqus

recent stream

  • @benhedrington
    A good Product Manager is critical and often misunderstood. >> "Product Manager You Are…a janitor, essentially.". http://t.co/BmUuJ5wO5I
  • @benhedrington
    "...design is merging with development... ...building the right product for the right use..." via @davidhussman #minnebar
  • @benhedrington
    "...what they forget is velocity is speed AND vector..." via @davidhussman
  • @benhedrington
    "...I'm encouraged today more engineers are trying to tell the product story..." via @davidhussman #minnebar
  • @benhedrington
    David Hussman kicking off Session 0 at #minnebar talking about reducing the weight of how you do work. http://t.co/1Uy5M9nESM

recent meta posts

creator / co-creator of...