How to mount Dropbox on Debian linux server (shell)
Thinking of backuping things on my VPS first of all i thought to mount a share from my home computer. But there are two reason i brought this idea away: thought my PC is almost always on, it still almost. And if one day a want to reinstall my PC for any reason i’d have to configure everything again. Another reason is that it would be a complicated aproach to create a secure connection (using Windows at home, just need it for gaming). So, i decided to look into possibility to backup thing to some kind of cloud storage. Made a comparison of different ones, but most of there need a GUI application to be installed which is not an option for a linux server. Another option was Cyphertite which provides 8GB free and highest security. But this kind security would be too high for me (a key is being used to connect to the storage and if it is lost, service provider has nothing to help you with). Best option for me i found several articles about how to configure it on a pure linux box was Dropbox. So here i’ll tell you how easy it is to make it working and also how to make it run as a daemon.
Dropbox is running per user sessions and mounts the storage under the user’s home folder. Considering that the storage on this server is only to be used for automated backups i decide to run it under root. There might be some considerations posted around internet about that you better avoid running side services with root, but in my case i do not really see any big security issue here. Just want to make everything simple. So, lets begin with logging in with root:
su # enter your root password cd ~
Installation binary packages and sources are available on Dropbox.com webpage: https://www.dropbox.com/install?os=lnx
Just right-click and copy the link. Then go to your linux server (i’m using Putty to connect to remote linux machine shell) and download the installation file:
# Copy your URL instead of mine. I'm using Debian 32-bit version that is current for the time this article is being written. wget https://www.dropbox.com/download?dl=packages/debian/dropbox_1.6.0_i386.deb
Now lets install the package. Remember, after installation Dropbox will be mounted under home folder that belongs to the user that is running that installation. In our case we’re installing the package with “root”, so the storage will be mounted here: “/root/Dropbox”.
dpkg -i dropbox_1.6.0_i386.deb
If the installation has been terminated due to some dependencies have not been installed then run
apt-get -f install
Now you can run the following to get dropbox commands:
dropbox
Lets start the Dropbox application:
dropbox start
On the first start it will drop you a link that you have to copy into your browser. Remember, you have to be logged into wordpress to activate your linux machine in your account. Of course, i forgot to tell you that you have to register your account on Dropbox before starting, but i don’t i need to write it here how this thing is done.
You can check your Dropbox process statuss by running
dropbox status
Now lets got and create dropbox startup script.
nano /etc/init.d/dropbox
Copy the following code into the file:
#!/bin/sh # dropbox service # Replace with linux users you want to run Dropbox clients for DROPBOX_USERS="keenan" DAEMON=.dropbox-dist/dropbox start() { echo "Starting dropbox..." for dbuser in $DROPBOX_USERS; do HOMEDIR=`getent passwd $dbuser | cut -d: -f6` if [ -x $HOMEDIR/$DAEMON ]; then HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON fi done } stop() { echo "Stopping dropbox..." for dbuser in $DROPBOX_USERS; do HOMEDIR=`getent passwd $dbuser | cut -d: -f6` if [ -x $HOMEDIR/$DAEMON ]; then start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON fi done } status() { for dbuser in $DROPBOX_USERS; do dbpid=`pgrep -u $dbuser dropbox` if [ -z $dbpid ] ; then echo "dropboxd for USER $dbuser: not running." else echo "dropboxd for USER $dbuser: running (pid $dbpid)" fi done } case "$1" in start) start ;; stop) stop ;; restart|reload|force-reload) stop start ;; status) status ;; *) echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}" exit 1 esac exit 0
Make this script executable:
chmod 755 /etc/init.d/dropbox
Lets get the script start automatically. Open “/etc/rc.local” file and enter this line above “exit 0″:
/etc/init.d/dropbox start
Now you can reboot your server and check if the the service is running. Try to create a new file there from your linux machine and check using your browser if the replication has been successfull and your file is now available at your Dropbox storage.
This is it!
Information about start-up script is brought from here: http://linuxdrops.com/dropbox-using-command-line-interface/#
Soon I’ll write you about my solution of backing up my websites on to this Dropbox storage.
Cya!