Permalink
Browse files

Add "lpreserver status" command, which will show last snapshot / repl…

…ication for all datasets
  • Loading branch information...
1 parent 176289d commit cb8f638240e3c0861293a0e1c8bfd41976f3f678 @kmoore134 kmoore134 committed Aug 16, 2013
Showing with 36 additions and 0 deletions.
  1. +17 −0 src-sh/lpreserver/backend/functions.sh
  2. +19 −0 src-sh/lpreserver/lpreserver
@@ -348,3 +348,20 @@ save_rep_props() {
return 1
fi
}
+
+listStatus() {
+
+ for i in `grep "${PROGDIR}/backend/runsnap.sh" /etc/crontab | awk '{print $8}'`
+ do
+ echo -e "DATASET - SNAPSHOT - REPLICATION"
+ echo "------------------------------------------"
+
+ lastSEND=`zfs get -r backup:lpreserver ${i} | grep LATEST | awk '{$1=$1}1' OFS=" " | tail -1 | cut -d '@' -f 2 | cut -d ' ' -f 1`
+ lastSNAP=`zfs list -t snapshot -d 1 -H ${i} | tail -1 | awk '{$1=$1}1' OFS=" " | cut -d '@' -f 2 | cut -d ' ' -f 1`
+
+ if [ -z "$lastSEND" ] ; then lastSEND="NONE"; fi
+ if [ -z "$lastSNAP" ] ; then lastSNAP="NONE"; fi
+
+ echo "$i - $lastSNAP - $lastSEND"
+ done
+}
@@ -50,6 +50,7 @@ cat<<__EOF__
cronsnap - Schedule snapshot creation via cron
revertsnap - Revert zpool/dataset to a snapshot
replicate - Enable / Disable ZFS replication to a remote system
+ status - List datasets, along with last snapshot / replication date
rmsnap - Remove a snapshot
__EOF__
};
@@ -177,6 +178,21 @@ Usage:
"
};
+help_status()
+{
+ title
+ echo "Help status
+
+List monitored dataset's last snapshot and replication
+
+Usage:
+
+ lpreserver status
+
+"
+};
+
+
help_listsnap()
{
title
@@ -308,6 +324,7 @@ case "$1" in
replicate) help_replicate ;;
cronsnap) help_cronsnap ;;
rmsnap) help_rmsnap ;;
+ status) help_status ;;
*) help_main ;;
esac ;;
@@ -378,6 +395,8 @@ revertsnap) require_root
SNAP="$3"
${PROGDIR}/backend/zfsrmsnap.sh "${DATASET}" "${SNAP}"
;;
+ status) listStatus
+ ;;
replicate) require_root
shift
case ${1} in

0 comments on commit cb8f638

Please sign in to comment.