Thursday, October 18, 2018

Running dropbox on old linux machines


Dropbox recently changed the linux system requirements. This may be a meaningful choice from the company's perspective, but I am not prepared to give-up on some of my old machines which have software that I find it hard to move to newer hardware. So, I was looking for a software solution that could work with ubuntu 10.04, ubuntu 11.04 and a relatively new centos machine which uses xfs instead of ext4. First I will describe the technical steps for the procedure I'm currently using, then I will discuss the shortcomings.


Technical steps (based on rclone and inotifywait)

[1] Install rclone as described in https://rclone.org/downloads/ . Surpisingly, this may be the hardest part of the procedure due to old versions of curl not being compatible with the server-side ssl. On both of my machines I had to install openssl from source and then install curl again from source (using the newest ssl libraries). Expect suffering at this stage.

[2] Configure rclone as described in https://rclone.org/dropbox/ . This is easy.

[3] Do a dry run to confirm that rclone is working as expected (change 'mydropbox' and 'user'):

rclone --dry-run sync -u mydropbox: /home/user/Dropbox


[4] Install inotify-tools if you don't have them already.

[5] If you reached this stage, you are practically done :


(a) Prepare a hidden file in your home directory (for example /home/user/.dropboxwatch.sh) containing the following bash script :


#!/bin/bash
while true; do

inotifywait -e modify,create -r /home/user/Dropbox && \
 pgrep rclone > /dev/null || rclone copy -u /home/user/Dropbox mydropbox:

done
exit

Make this file executable (with chmod 755 /home/user/.dropboxwatch.sh).


(b) Edit your crontab and insert the following two lines :


@reboot      /home/user/.dropboxwatch.sh >& /dev/null
*/30 * * * * pgrep rclone > /dev/null || rclone sync -u mydropbox: /home/user/Dropbox


(c) Add the following to your .bashrc :

alias dropboxfetch='pgrep rclone > /dev/null || rclone copy -u mydropbox: /home/user/Dropbox'


(d) Reboot the machine and confirm that .dropboxwatch.sh is running.



What you get from all that

(a) When you add a file to the dropbox directory of the local (old) machine, it will be immediately transferred to the dropbox servers (and, thus, to all of your other machines).

(b) When you modify the dropbox directory from other (non-old) machines, the changes in the old machines will appear at the time interval defined in the crontab (every 30 minutes in the example above). If you want to immediately fetch new files from dropbox to the local (old) machines use the dropboxfetch alias.

(c) You can not push file deletions from the old machines to dropbox. Dropbox files can only be deleted from newer machines that run the real dropbox daemon. The deletions will appear at the crontab specified interval. Think what you may, but this is a great precaution (and do note that at no point do we do a sync from the old machine to dropbox, which is the definition of better-safe-than-sorry).

Things can definitely go wrong. Notice for example these pgrep's ? These are to avoid some obvious race conditions that arise if you end-up having two rclone jobs running simultaneously. But I bet (especially with dropboxfetch) you can still get artifacts. The thing is that in the absence of a sync from the old machine to dropbox, the worst case scenario is that some files you thought you deleted, may end-up being well and alive. (famous last words I hear you say).




No comments:

Post a Comment