3 # backup-script system for cloning systems using rsync
4 # Copyright (c)2008-2014 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.
19 declare -i snapshots=0
21 # Default settings, can be overwritten in backup-script.conf:
22 conf_d="/etc/backup-script.d"
26 for conf in "/etc/backup-script.conf" "${conf_d}/backup-script.conf"; do
27 if [ -r "$conf" ]; then
36 if [ "$QUICK" = "0" ]; then
37 size=`du -sh "$1" | cut -f1`
38 echo "$2 - Size:" $size
47 last=`stat "$1" | grep "^Modify: " \
48 | cut -d':' -f2- | cut -d. -f1`
49 [ -n "$last" ] && echo "$2 - Date:" $last
54 24) txt=", WARNING (some files vanished during backup)"; ;;
57 [ -n "$code" ] && echo "$2 - Result code: $code$txt"
59 echo "$2 - No timestamp recorded! Backup currently running or aborted?"
63 if [ "$1" == "-q" ]; then
70 echo "Usage: $NAME [-q] [<system> [<system> [...]]]"
77 if [ ! -r "${conf_d}/$s" ]; then
78 echo "$NAME: Can' read \"${conf_d}/$s\"!"
81 sys="$sys ${conf_d}/$s"
87 [ -r "${conf_d}/backup-script.conf" ] && source "${conf_d}/backup-script.conf"
90 [ -r "$f" -a -f "$f" ] || continue
94 "backup-script.conf"|*.sh)
101 target="$default_target"
102 generations="$default_generations"
104 # Read in system configuration file
107 # Validate configuration
108 [ "$system" = "localhost" -o "$system" = "127.0.0.1" ] && local=1
111 target="$target/$fname"
113 [ -d "$target" ] || continue
116 [ "$system" = "$fname" ] && echo "$fname" || echo "$fname [$system]"
118 # System target directory
119 echo "- Target: $target"
121 if [ $generations -gt 0 ]; then
122 for s in $target/[0-9]*-[0-9]*; do
123 echo " - Snapshot: $s"
125 Check_Stamp "$s/.stamp" " "
126 snapshots=$snapshots+1
129 # Timestamp and result code
131 Check_Stamp "$target/.stamp"
132 snapshots=$snapshots+1
139 if [ $count -lt 1 ]; then
140 echo "No backups found!"
143 [ $count -eq 1 ] && sc="" || sc="s"
144 [ $snapshots -eq 1 ] && ss="" || ss="s"
145 echo "$count system backup$sc found, $snapshots snapshot$ss."