How to Use Dropbox CLI for Backup Sync

Dropbox being a well-known free service lets you synchronize and share your data all over the world and no matter what computer or mobile device you are working with.

Particularly, this functionality becomes useful when it comes to backups. Interesting feature here is that you can use Dropbox CLI (stands for Command Line Interface) in any text-based Linux environment, thus significantly simplifying your life in terms of data safety.

The only important pre-requisite you should be aware of is Python 2.6 or higher. You can install it to a separate directory not to break your current Python installation (if any).

Assuming you’re already registered at www.dropbox.com, let’s follow a few simple steps below to get the whole thing up and running.

1. Obtain your shell prompt and download the archive which corresponds to your server architecture:

wget http://www.dropbox.com/download/?plat=lnx.x86

or

wget http://www.dropbox.com/download/?plat=lnx.x86_64

[alert]Use arch or uname -i commands to find out what hardware platform you’re running.[/alert]

2. Extract the archive and run dropboxd:

tar xzvf dropbox-lnx.x86_64-1.1.45.tar.gz

https://www.dropbox.com/cli_link?host_id=0108897c509a892ddf803303f5fc5000&cl=en_US

3. You will see the output message similar to this:

This client is not linked to any account… Please visit https://www.dropbox.com/cli_link?host_id=3d34y857ar54*** to link this machine.

Now copy that URL and paste it in your web browser. Next, verify your account by typing your Dropbox password.

That’s all. Now this server is linked to your account and you can manage it through the web interface (Account -> My Computers tab). Also, the directory ‘~/Dropbox’ is created on the server and your files start syncing immediately.

4. Here we’ll perform some steps to implement easy-to-use philosophy of managing the Dropbox installation.

Download the following script to one of your $PATH directories.

cd /usr/bin

wget http://www.dropbox.com/download?dl=packages/dropbox.py

mv dropbox.py dropbox

chmod 0700 dropbox

Type ‘dropbox’ to see all available options provided by this script.

[alert]If you saw ‘invalid syntax’ errors while running this script – open the script with your favorite editor and edit the shebang line ‘#!/usr/bin/python’ to match your valid Python 2.6+ installation path, i. e. ‘#!/opt/python26′.[/alert]

6. Being a Dropbox user you’re probably aware of the ‘LAN sync’ option. We’re going to disable this feature as most likely you do not manage a LAN and therefore don’t require this. Use the following commands:

dropbox stop

cd /usr/bin

wget http://dl.dropbox.com/u/340607/pyDropboxValues.py

chmod 0700 pyDropboxValues.py

./pyDropboxValues.py

wget http://dl.dropbox.com/u/340607/dropbox_set_lansync.py

chmod 0700 dropbox_set_lansync.py off

dropbox_set_lansync.py

dropbox start

7. Let’s enable autoloading and create the init script.

Debian-based distributive (like Ubuntu):

cd /etc/init.d

wget http://dl.dropbox.com/u/17184781/bin3/dropbox_debian

mv dropbox_debian dropbox

chmod 0700 dropbox

update-rc.d dropbox defaults

 

RedHat-based distributive (like CentOS):

cd /etc/init.d

wget http://dl.dropbox.com/u/17184781/bin3/dropbox_redhat

mv dropbox_redhat dropbox

chmod 0700 dropbox

echo 'DROPBOX_USERS="root"' > /etc/sysconfig/dropbox

chkconfig dropbox on

Where ‘root’ is the user under which you’re running your Dropbox. You might want to create a different user for security reasons.

We’re all set. Copy any file to ‘~/Dropbox’ directory and it will be synchronized within a moment to Dropbox cloud.

You might also want to add a cron job to have some specific directories synchronized automatically within the specific time frames. If you tried everything and for some strange reason a directory is not synced – try sharing it using Dropbox web interface.


Was this article helpful?
Spread the word!