Linux dropbox – pause from command and cron
Background
I use duplicity (compressed & encrypted differential backups) and need to replicate these off-site. One of the more cost effective ways to to this is use cloud storage such as drop box. I wanted to take advantage of the drop box client installed on a user account on my server and avoid the hassle of writing scripts to use the drop box api to keep the file stores in sync.
This works fine but the dropbox function works as a user process then the user is logged in. No problem except if you use a cron job / cli to stop the process and restart you loose the icon on the desktop.
So why do I want to stop start? Simples – I have “free” bandwidth between 11pm and 8am and would rather upload Gbytes of backup then.
So how do I stop this running from cron each day and restart without interring with the user control widget?
The sledge-hammer approach seems to be to stop the process by sending it a signal and then continue the process when the bandwidth is free. Amazingly this seems to work. How do you do this? To stop a process send a kill -STOP signal to the process and to restart use kill -CONT. The drop box usermode daemon usefully records it’s process ID (PID) in <user home>/.dropbox/dropbox.pid so pick it from there.
The resultant script I use can be seen below and is called with % script.sh [ STOP | START ]
The script:
#!/bin/bash PID=`cat ~/.dropbox/dropbox.pid` if [ "$1" == "STOP" ] then kill -STOP $PID elif [ "$1" == "START" ] then kill -CONT $PID else echo "I do not understand - use START or STOP " fi ps -aux | grep $PID
Leave a comment