X-Git-Url: http://git.pippins.net/embedvideo/.git/static/gitweb.js?a=blobdiff_plain;f=zfs-replicate;h=7c6e65027f64f40f6af4bc56860bda74a688bfc1;hb=80e5913b92d256486d08d966ab2fa34d2d6046fb;hp=ef90b54a40148d6077fe6655348654a3610520e1;hpb=e5bbf1952d51ab406d73ddb49496422c2d7ebb61;p=zfs-ubuntu%2F.git diff --git a/zfs-replicate b/zfs-replicate index ef90b54..7c6e650 100755 --- a/zfs-replicate +++ b/zfs-replicate @@ -6,6 +6,9 @@ set -x remote=$1 remote_fs=$2 +# change to match the name of the local backup pool +local_pool=backups + # The ssh connection doesn't find zfs without this. zfs=/usr/sbin/zfs @@ -19,8 +22,8 @@ ssh $remote \ # List the snapshots on the local machine. local_list=$(mktemp /tmp/replicate.XXXXXX) $zfs list -H -t snapshot | - grep ^backups/${remote_fs}@ | - awk '{gsub(/^backups./,"",$1); print$1}' > $local_list + grep ^${local_pool}/${remote_fs}@ | + awk '{gsub(/^${local_pool}./,"",$1); print$1}' > $local_list # See what the most recent snapshot on the remote end is. latest=$(tail -n 1 $remote_list) @@ -30,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 backups/${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