Added a restore helper script
[rrq/buckap.git] / duplicity-daily
1 #!/bin/bash
2 #
3 # Backup directories daily. Configuration at /etc/duplicity-daily
4
5 # Requires dupltool
6 [ -x /usr/bin/dupltool ] || exit 0
7
8 CONFIG=/etc/duplicity-daily.conf
9 grep -q ^ENABLE=yes $CONFIG || exit 0
10
11 # Detail backup options
12 OPTIONS=( $(grep ^OPTIONS= $CONFIG | sed 's/^OPTIONS=//') )
13
14 # The default backup target
15 TARGET="$(grep ^TARGET= -m1 $CONFIG | sed 's/^TARGET=//')"
16
17 # Backup lines start with full path, optionally with =target
18 # No spaces in pathname or target, e.g.
19 # /home
20 # /opt/other/x=user@host/backup/x
21
22 SRCS=( $(grep ^/ $CONFIG) )
23 for SRC in "${SRCS[@]}" ; do
24     if [ "${SRC#*=}" = "$SRC" ] ; then
25         DST=$TARGET$SRC
26     else
27         DST="${SRC##*=}"
28         SRC="${SRC%%=*}"
29     fi
30     echo "** Backing up $SRC to $DST" 
31     dupltool ${OPTIONS[*]} $SRC pexpect+scp://$DST
32 done |& logger -t backup