> From: Discussion list for OpenIndiana [mailto:openindiana-
> [email protected]]
> 
> On our backup servers I have a "backup-check" script that checks to see
> what the last snapshot for a particular volume is (and compares it with the
> current date)

This is how I do it:
By doing "zfs list" once and caching in tmpfile, I can easily parse with grep 
many times over.

Obviously, according to the script below, my snapshots are named 
@AutoRotate-`date '+%F'`

#!/usr/bin/bash
export PATH=/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin
export TODAY=`date '+%F'`
TMPFILE=`mktemp /tmp/tmp.XXXXXXXX`    # mktemp will randomize XXXXXXX
zfs list -H -o name -t snapshot > $TMPFILE

filesystems=`zfs list -H -o name -t filesystem,volume | egrep -v 
'rpool/dump|rpool/swap'`
for fs in $filesystems ; do 
    latest=`grep "^${fs}@" $TMPFILE | tail -1`
    if ( echo $latest | grep -q $TODAY ) ; then
        echo "good      $latest"
    else
        if ( grep -q "^${fs}@" $TMPFILE ) ; then
            latest=`echo $latest | sed 's/^.*@AutoRotate-//'`
            echo "outdated $latest $fs"
        else
            echo "not found $fs"
        fi
    fi
done
rm $TMPFILE

_______________________________________________
OpenIndiana-discuss mailing list
[email protected]
http://openindiana.org/mailman/listinfo/openindiana-discuss

Reply via email to