Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Add "lpreserver status" command, which will show last snapshot / repl…
Browse files Browse the repository at this point in the history
…ication for all datasets
  • Loading branch information
Kris Moore committed Aug 16, 2013
1 parent 176289d commit cb8f638
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src-sh/lpreserver/backend/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
19 changes: 19 additions & 0 deletions src-sh/lpreserver/lpreserver
Original file line number Diff line number Diff line change
Expand Up @@ -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__
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -308,6 +324,7 @@ case "$1" in
replicate) help_replicate ;;
cronsnap) help_cronsnap ;;
rmsnap) help_rmsnap ;;
status) help_status ;;
*) help_main ;;
esac ;;

Expand Down Expand Up @@ -378,6 +395,8 @@ revertsnap) require_root
SNAP="$3"
${PROGDIR}/backend/zfsrmsnap.sh "${DATASET}" "${SNAP}"
;;
status) listStatus
;;
replicate) require_root
shift
case ${1} in
Expand Down

0 comments on commit cb8f638

Please sign in to comment.