Added code to deal with not finding a common snapshot
authorAlan J. Pippin <ajp@pippins.net>
Tue, 13 Jan 2009 03:49:21 +0000 (20:49 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Tue, 13 Jan 2009 03:49:21 +0000 (20:49 -0700)
zfs-replicate

index 7f93696da6b12e29119e9a56236913ff02b4bd26..7c6e65027f64f40f6af4bc56860bda74a688bfc1 100755 (executable)
@@ -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