]> arthur.barton.de Git - backup-script.git/blob - bin/backup-status
Add /run to hardcoded exclude list
[backup-script.git] / bin / backup-status
1 #!/bin/bash
2 #
3 # backup-script system for cloning systems using rsync
4 # Copyright (c)2008-2013 Alexander Barton, alex@barton.de
5 #
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.
11 #
12
13 NAME=`basename $0`
14 CONF_D="/etc/backup-script.d"
15 QUICK=0
16
17 export LC_ALL=C
18
19 declare -i count=0
20
21 default_target=""
22 default_user="root"
23
24 if [ "$1" == "-q" ]; then
25         QUICK=1
26         shift
27 fi
28
29 case "$1" in
30     "-"*)
31         echo "Usage: $NAME [-p] [<system> [<system> [...]]]"
32         exit 1
33         ;;
34 esac
35
36 if [ $# -ge 1 ]; then
37         for s in $@; do
38                 if [ ! -r "${CONF_D}/$s" ]; then
39                         echo "$NAME: Can' read \"${CONF_D}/$s\"!"
40                         exit 1
41                 fi
42                 sys="$sys ${CONF_D}/$s"
43         done
44 else
45         sys=${CONF_D}/*
46 fi
47
48 [ -r "${CONF_D}/backup-script.conf" ] && source "${CONF_D}/backup-script.conf"
49
50 for f in $sys; do
51         [ -r "$f" -a -f "$f" ] || continue
52
53         system=`basename $f`
54         target="$default_target"
55
56         case "$system" in
57                 "backup-script.conf"|*.sh)
58                         continue
59                         ;;
60         esac
61
62         # Read in configuration file
63         source "$f"
64
65         destdir="$target"
66         target="$target/$system"
67
68         [ -d "$target" ] || continue
69
70         echo "$system"
71         echo "- Target: $target"
72         if [ "$QUICK" = "0" ]; then
73                 size=`du -sh "$target" | cut -f1`
74                 echo "- Size:" $size
75         fi
76         if [ -f "$target/.stamp" ]; then
77                 last=`stat "$target/.stamp" | grep "^Modify: " | cut -d':' -f2- | cut -d. -f1`
78                 [ -n "$last" ] && echo "- Date:" $last
79                 unset code
80                 source "$target/.stamp"
81                 [ -n "$code" ] && echo "- Result code:" $code
82         else
83                 echo "- No timestamp recorded!?"
84         fi
85
86         count=$count+1
87         echo
88 done
89
90 if [ $count -lt 1 ]; then
91         echo "No backups found!"
92         exit 1
93 fi
94 echo "$count system backup(s) found."
95
96 # -eof-