Hush error output from ls when no monthly backups are present.
authorSugar Labs BOFH <sysadmin@sugarlabs.org>
Thu, 2 Feb 2017 03:37:44 +0000 (22:37 -0500)
committerSugar Labs BOFH <sysadmin@sugarlabs.org>
Thu, 2 Feb 2017 03:37:44 +0000 (22:37 -0500)
Also fix printing the full command line in the log.

wizbackup

index fffd3b9f11f08d1440bdbb69bfe3f60221f349e0..746cfba7022435e3c1924188fa2c09ed329c0ce0 100755 (executable)
--- a/wizbackup
+++ b/wizbackup
@@ -116,7 +116,7 @@ do_init() {
 do_prune() {
        local num_snapshots="$1"
        local suffix="$2"
-       local oldest="$(ls -d [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$suffix | head -n -$num_snapshots)"
+       local oldest="$(ls 2>/dev/null -d [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$suffix | head -n -$num_snapshots)"
        for old in $oldest; do
                echo "$(date): Removing oldest snapshot(s): $old..."
                rm -rf "$old" || exit 669
@@ -173,8 +173,7 @@ do_test() {
 # make sure to be root
 if (( `id -u` != 0 )); then { echo "Sorry, must be root.  Exiting..."; exit; } fi
 
-echo "$(date): BEGIN backup: $0 $@"
-echo "$(date): $0 $SRC $DEST $@"
+echo "$(date): BEGIN backup: $0 $SRC $DEST $@"
 do_init
 do_prune 6 ""
 do_prune 4 "-weekly"