Re: daily(8): don't fail silently if backup disk is unavailable

2018-02-06 Thread Ingo Schwarze
Hi Theo,

Theo Buehler wrote on Mon, Feb 05, 2018 at 12:13:31PM +1300:

> After a power failure, my apu2 booted, but its sdmmc controller didn't
> attach properly. A few days later I was wondering why I didn't get the
> usual dump output from the backup of the root filesystem in my daily
> mails.
> 
> It turns out that daily(8) fails silently if it can't find the backup
> volume. Since this happens due to a failure of some kind or because of
> misconfiguration, I suggest that we print an error message, so this can
> be easily spotted in the mail.

That makes a lot of sense to me.

The patch reads well and survived basic testing.

OK schwarze@
  Ingo

>
 Index: etc/daily
> ===
> RCS file: /var/cvs/src/etc/daily,v
> retrieving revision 1.90
> diff -u -p -r1.90 daily
> --- etc/daily 10 Jul 2017 11:18:48 -  1.90
> +++ etc/daily 4 Feb 2018 22:28:12 -
> @@ -90,7 +90,10 @@ while [ "X$ROOTBACKUP" = X1 ]; do
>   fi
>   rootbak=${rootbak#/dev/}
>   bakdisk=${rootbak%%?(.)[a-p]}
> - sysctl -n hw.disknames | grep -Fqw $bakdisk || break
> + if ! sysctl -n hw.disknames | grep -Fqw $bakdisk; then
> + echo "Backup disk '$bakdisk' not available in hw.disknames."
> + break
> + fi
>   bakpart=${rootbak##$bakdisk?(.)}
>   OLDIFS=$IFS
>   IFS=,



daily(8): don't fail silently if backup disk is unavailable

2018-02-04 Thread Theo Buehler
After a power failure, my apu2 booted, but its sdmmc controller didn't
attach properly. A few days later I was wondering why I didn't get the
usual dump output from the backup of the root filesystem in my daily
mails.

It turns out that daily(8) fails silently if it can't find the backup
volume. Since this happens due to a failure of some kind or because of
misconfiguration, I suggest that we print an error message, so this can
be easily spotted in the mail.

Index: etc/daily
===
RCS file: /var/cvs/src/etc/daily,v
retrieving revision 1.90
diff -u -p -r1.90 daily
--- etc/daily   10 Jul 2017 11:18:48 -  1.90
+++ etc/daily   4 Feb 2018 22:28:12 -
@@ -90,7 +90,10 @@ while [ "X$ROOTBACKUP" = X1 ]; do
fi
rootbak=${rootbak#/dev/}
bakdisk=${rootbak%%?(.)[a-p]}
-   sysctl -n hw.disknames | grep -Fqw $bakdisk || break
+   if ! sysctl -n hw.disknames | grep -Fqw $bakdisk; then
+   echo "Backup disk '$bakdisk' not available in hw.disknames."
+   break
+   fi
bakpart=${rootbak##$bakdisk?(.)}
OLDIFS=$IFS
IFS=,