From: Alan J. Pippin <ajp@pippins.net>
Date: Tue, 13 Jan 2009 03:49:21 +0000 (-0700)
Subject: Added code to deal with not finding a common snapshot
X-Git-Url: http://git.pippins.net/%27.%24link.%27?a=commitdiff_plain;h=80e5913b92d256486d08d966ab2fa34d2d6046fb;p=zfs-ubuntu%2F.git

Added code to deal with not finding a common snapshot
---

diff --git a/zfs-replicate b/zfs-replicate
index 7f93696..7c6e650 100755
--- a/zfs-replicate
+++ b/zfs-replicate
@@ -33,7 +33,14 @@ echo bogus.remote >> $remote_list
 echo bogus.local  >> $local_list
 common=$(diff -u $remote_list $local_list | grep '^ ' | tail -n 1)
 
-ssh $remote $zfs send -R -I${common/*@/@} $latest |
-    $zfs receive -vF -d ${local_pool}/${remote_fs%/*}
+if [ -n "$common" ]; then 
+  # We found a common snapshot
+  ssh $remote $zfs send -R -I${common/*@/@} $latest |
+      $zfs receive -vF -d ${local_pool}/${remote_fs%/*}
+else
+  # We did not find a common snapshot, so send the entire filesystem
+  ssh $remote $zfs send -R $latest |
+      $zfs receive -vF -d ${local_pool}/${remote_fs%/*}
+endif
 
 rm -f $local_list $remote_list