--- /dev/null 2010-07-22 20:33:01.000000000 +0200 +++ etc/periodic/daily/220.backup-geom 2010-07-22 20:09:13.000000000 +0200 @@ -0,0 +1,49 @@ +#!/bin/sh +# +# $FreeBSD:$ +# + +# If there is a global system configuration file, suck it in. +# +if [ -r /etc/defaults/periodic.conf ] +then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +case "$daily_backup_gpart_enable" in + [Yy][Ee][Ss]) + temp=/tmp/gpart_temp.bak + gpart show > $temp + if [ ! -s $temp ] + then + echo "nothing to backup" + rm $temp || rc=2 + else + bak=/var/backups + rc=0 + + echo "" + echo "Backing up geom partition information:" + + if [ ! -f $bak/gpart.bak ] + then + echo "no $bak/gpart.bak" + mv $temp $bak/gpart.bak || rc=3 + + elif ! cmp -s $bak/gpart.bak $temp + then + [ $rc -lt 1 ] && rc=1 + echo "geom partition layout has been altered:" + diff -u $bak/gpart.bak $temp + mv $bak/gpart.bak $bak/gpart.bak2 + mv $temp $bak/gpart.bak || rc=3 + else + echo "geom partition layout hasn't been altered. skipping backup." + fi + fi;; + + *) rc=0;; +esac + +exit $rc