17 July 2012

Dropbox integration with EC2 Linux instance

So Dropbox has a great linux command line tool which comes in very useful for copying files to your Amazon linux EC2 instance, without having to open up FTP or copying each file by hand. It took me ages figuring out how to set this up, but it saves a lot of time.

First we download dropbox and unzip it:
$ wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"
$ tar -xvzf dropbox.tar.gz
Run it:
$ ~/.dropbox-dist/dropboxd &

..and you should see a message like this:
"This client is not linked to any account... Please visit https://www.dropbox.com/cli_link?host_id=XXXXX to link this machine."
Copy/paste that URL into a Web browser on your local machine; log into dropbox; and voila! The directory ~/Dropbox will be linked into your home directory! The repeating message on your console should then stop. If it doesn't press Ctrl+C.

You should now see a new folder called "Dropbox" sync'd with your dropbox account.

Now we need a package called dropbox.py, this is the dropbox command line tool. Very useful, if a little tricky to use sometimes.

$ wget -O ~/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py"

First there's a few folders we don't want sync'd so we add them to the exclude list.

$ python dropbox.py exclude add ~/Dropbox/Public   
Excluded: 
Dropbox/public
$ python dropbox.py exclude add ~/Dropbox/Photos 
Excluded: 
Dropbox/photos

Now we're going to add a symbolic link. This links our dropbox folder to our web root.

$ python dropbox.py dropbox stop                   
Dropbox daemon stopped.
$ sudo mv ~/Dropbox /opt/railo/tomcat/webapps
$ ln -s /opt/railo/tomcat/webapps/Dropbox ~/
$ python dropbox.py dropbox start
Starting Dropbox...Done!

3 comments:

Unknown said...

Fantastic, thanks!

I modified some of your command lines based on https://www.dropbox.com/install?os=lnx

e.g. using 64 bit amazon linux ami

Mike said...

Couldn't start Dropbox
This is usually because of a permissions error. Errors can also be caused by your home folder being stored on a network share.

Get more help at https://www.dropbox.com/c/help/permissions_error

Please contact support with the following information for more help:

/tmp/dropbox_errort9mnle.txt
^C
[1]+ Exit 255 ~/.dropbox-dist/dropboxd

Unknown said...
This comment has been removed by a blog administrator.