Created the zfs-replicate-wrapper script that factors in duration to
[zfs-ubuntu/.git] / zfs-replicate
index dc6dab215c592241685f6f90eb017ab4e6f85ded..09cb3babb7600f0526a14b4b2c2f945f41660ea4 100755 (executable)
@@ -10,7 +10,7 @@ remote_lockdir="/tmp/zfs-admin-lock"
 local_pool=backups
 
 # Set the email address to send notification to
-mailto=alan@pippins.net
+mailto=root@pippins.net
 
 # When this variable is set, local filesystems will be destroyed 
 # before receiving a full streams into them from the remote source.
@@ -19,6 +19,14 @@ destroy_local_filesystem_on_full_replicate=0
 # The ssh connection doesn't find zfs without this.
 zfs=/usr/sbin/zfs
 
+# Setup our cleanup and exit trap
+cleanup() {
+  ssh $remote rm -rf "$remote_lockdir"
+  exit
+}
+trap cleanup INT
+trap cleanup EXIT
+
 # Make sure we have valid arguments
 if [[ -z "$remote" ]] || [[ -z "$remote_fs" ]]; then
   echo "Usage: $0 <hostname> <zfs filesystem>"
@@ -78,10 +86,6 @@ while true; do
   fi
 done
 
-# Declare a cleanup() method to remove the remote lockdir
-cleanup() { ssh $remote rm -rf "$remote_lockdir"; }
-trap cleanup EXIT
-
 # Setup our backup marker names
 current_backup_marker=${remote_fs}@current-backup-${local_pool_guid}
 previous_backup_marker=${remote_fs}@previous-backup-${local_pool_guid}