]> arthur.barton.de Git - backup-script.git/blobdiff - bin/backup-status
Autodetect "localhost" and 127.0.0.1 as being "local"
[backup-script.git] / bin / backup-status
index 3948645362f87465f64620f059b98392a9017ff9..bbb6b056265baa6e2e68fc9005d69cee10915c4b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # backup-script system for cloning systems using rsync
 # Copyright (c)2008-2013 Alexander Barton, alex@barton.de
@@ -18,8 +18,8 @@ export LC_ALL=C
 
 declare -i count=0
 
+# Default settings, can be overwritten in backup-script.conf:
 default_target=""
-default_user="root"
 
 if [ "$1" == "-q" ]; then
        QUICK=1
@@ -50,36 +50,47 @@ fi
 for f in $sys; do
        [ -r "$f" -a -f "$f" ] || continue
 
-       system=`basename $f`
-       target="$default_target"
-
-       case "$system" in
+       fname=`basename $f`
+       case "$fname" in
                "backup-script.conf"|*.sh)
                        continue
                        ;;
        esac
 
-       # Read in configuration file
+       # Set global defaults
+       system="$fname"
+       target="$default_target"
+
+       # Read in system configuration file
        source "$f"
 
+       # Validate configuration
+       [ "$system" = "localhost" -o "$system" = "127.0.0.1" ] && local=1
+
        destdir="$target"
        target="$target/$system"
 
        [ -d "$target" ] || continue
 
-       echo "-- $system -- "
-       echo "Storage: $target"
+       # System name
+       [ "$system" = "$fname" ] && echo "$system" || echo "$system [$fname]"
+
+       # System target directory
+       echo "- Target: $target"
        if [ "$QUICK" = "0" ]; then
-               size=$( du -sh "$target" | cut -f1 )
-               echo "Size: $size"
+               size=`du -sh "$target" | cut -f1`
+               echo "- Size:" $size
        fi
+
+       # Timestamp and result code
        if [ -f "$target/.stamp" ]; then
-               stat "$target/.stamp" | grep "^Modify: " | cut -d. -f1
+               last=`stat "$target/.stamp" | grep "^Modify: " | cut -d':' -f2- | cut -d. -f1`
+               [ -n "$last" ] && echo "- Date:" $last
                unset code
                source "$target/.stamp"
-               [ -n "$code" ] && echo "Result code: $code"
+               [ -n "$code" ] && echo "- Result code:" $code
        else
-               echo "No timestamp recorded!?"
+               echo "No timestamp recorded!?"
        fi
 
        count=$count+1
@@ -90,6 +101,6 @@ if [ $count -lt 1 ]; then
        echo "No backups found!"
        exit 1
 fi
-echo "$count system backups found."
+echo "$count system backup(s) found."
 
 # -eof-