--- /dev/null
+#!/bin/bash
+
+# contab example to backup every configuration:
+# */1 * * * * /mnt/wd/ext/backup/bin/trigger -a
+#
+# additional verbose logging:
+# */1 * * * * /mnt/wd/ext/backup/bin/trigger -a -l /var/log/trigger.log
+#
+# backup of configurations 'foo' and 'bar'
+# */1 * * * * /mnt/wd/ext/backup/bin/trigger foo bar
+
+function log {
+ [ "$dolog" = "1" ] && echo "`date` - $@" >> $log
+}
+
+mode=single
+confs=""
+log=""
+for arg in "$@"; do
+ case $arg in
+ -a)
+ mode=all
+ shift
+ ;;
+ -l)
+ log=$2
+ shift 2
+ ;;
+ *)
+ confs="$arg $confs"
+ shift
+ ;;
+ esac
+done
+
+prog=$0
+pdir=`dirname $prog`
+cdir=$pdir/../config
+
+dolog=0
+if [ ! -z "$log" ]; then
+ mkdir -p `dirname $log`
+ [ -d `dirname $log` ] && dolog=1
+fi
+
+if [ "$mode" = "all" ]; then
+ confs=""
+ for cf in $cdir/*.conf; do
+ confs="`basename $cf | sed 's/\.conf$//'` $confs"
+ done
+fi
+
+log triggering backup of $confs ...
+for conf in $confs; do
+ if [ -f $cdir/${conf}.conf ]; then
+ rp=`ps -ef | grep "[c]onfig/${conf}\.conf"`
+ if [ -z "$rp" ]; then
+ cmd="$pdir/backup $cdir/${conf}.conf"
+ log started backup of $conf ...
+ nohup $cmd &>/dev/null &
+ else
+ log backup of $conf in progress ...
+ fi
+ else
+ log no configuration found for $conf, doing nothing ...
+ fi
+done
+log triggering completed, terminating ...
+