inotify triggered backups
This series of scripts and settings are to allow clients to trigger backups via inotify. I created this to allow my computers, such as my laptop, that are not always on to be backed up by dirvish. This can handle running on more than one client at a time.
This is my first wiki, so bear with me. Also, feel free to make suggestions.
I created this on a Gentoo server.
I am using the directory "/var/tmp/dirvish/personal" as my trigger directory
You will need a package called "incron" This handles the trigger portion of this setup. Make sure you have set incron to start on boot.
Run incrontab -e as the user you wish to handle the backups, and use these settings:
"/var/tmp/dirvish/personal IN_CREATE /root/bin/dirvish-personal-run $#"
This will monitor the directory "/var/tmp/dirvish/personal" for newly created files only, and when it finds one, it will pass that filename to the /root/bin/dirvish-personal-run script. Since things only trigger on newly created files, this also keeps dirvish from trying to run more than once on a client during a time period.
The contents of the dirvish-personal-run script:
DIRVISH_CLIENT=$1 BANK_ROOT=/home/dirvish/personal # Run Dirvish cd $BANK_ROOT/$DIRVISH_CLIENT for VAULT in $(ls -1 |grep -v lost) ; do /usr/sbin/dirvish-expire --vault $VAULT --quiet /usr/sbin/dirvish --vault $VAULT done
Now, on the clients, make sure you can use ssh without a password if you want to run it via cron, and use the following as your cron script at the time of your choosing (I run mine at 1am):
echo `hostname -s` | ssh dirvish_server 'echo $SSH_CLIENT > /var/tmp/dirvish/personal/`cat`'
Currently, the client is set to put the contents of the $SSH_CLIENT in the trigger file, for the ip. My next step is to handle remote connections, and this may be needed, but I am not that far along yet. If you do not want this, use the following as your client's cron entry:
ssh dirvish_server touch /var/tmp/dirvish/personal/`hostname -s`
Lastly, on the server, you need a cron entry to delete the trigger files so dirvish can run again. I run mine at midnight:
rm -f /var/tmp/dirvish/personal/*
(2008 Feb 14 -- I made an attachment out of your script -- keithl)
