3 # backup-script system for cloning systems using rsync
4 # Copyright (c)2008-2013 Alexander Barton, alex@barton.de
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
14 CONF_D="/etc/backup-script.d"
20 declare -i snapshots=0
22 # Default settings, can be overwritten in backup-script.conf:
30 if [ "$QUICK" = "0" ]; then
31 size=`du -sh "$1" | cut -f1`
32 echo "$2 - Size:" $size
41 last=`stat "$1" | grep "^Modify: " \
42 | cut -d':' -f2- | cut -d. -f1`
43 [ -n "$last" ] && echo "$2 - Date:" $last
48 24) txt=", WARNING (some files vanished during backup)"; ;;
51 [ -n "$code" ] && echo "$2 - Result code: $code$txt"
53 echo "$2 - No timestamp recorded!? Backup aborted?"
57 if [ "$1" == "-q" ]; then
64 echo "Usage: $NAME [-q] [<system> [<system> [...]]]"
71 if [ ! -r "${CONF_D}/$s" ]; then
72 echo "$NAME: Can' read \"${CONF_D}/$s\"!"
75 sys="$sys ${CONF_D}/$s"
81 [ -r "${CONF_D}/backup-script.conf" ] && source "${CONF_D}/backup-script.conf"
84 [ -r "$f" -a -f "$f" ] || continue
88 "backup-script.conf"|*.sh)
95 target="$default_target"
96 generations="$default_generations"
98 # Read in system configuration file
101 # Validate configuration
102 [ "$system" = "localhost" -o "$system" = "127.0.0.1" ] && local=1
105 target="$target/$fname"
107 [ -d "$target" ] || continue
110 [ "$system" = "$fname" ] && echo "$fname" || echo "$fname [$system]"
112 # System target directory
113 echo "- Target: $target"
115 if [ $generations -gt 0 ]; then
116 for s in $target/[0-9]*-[0-9]*; do
117 echo " - Snapshot: $s"
119 Check_Stamp "$s/.stamp" " "
120 snapshots=$snapshots+1
123 # Timestamp and result code
125 Check_Stamp "$target/.stamp"
126 snapshots=$snapshots+1
133 if [ $count -lt 1 ]; then
134 echo "No backups found!"
137 [ $count -eq 1 ] && sc="" || sc="s"
138 [ $snapshots -eq 1 ] && ss="" || ss="s"
139 echo "$count system backup$sc found, $snapshots snapshot$ss."