From: Sugar Labs BOFH Date: Thu, 2 Feb 2017 03:37:44 +0000 (-0500) Subject: Hush error output from ls when no monthly backups are present. X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=6ad810ad8ebc496ea2b64f9ad86d2fd2cb28bd03;p=wizbackup.git Hush error output from ls when no monthly backups are present. Also fix printing the full command line in the log. --- diff --git a/wizbackup b/wizbackup index fffd3b9..746cfba 100755 --- 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"