diff options
-rwxr-xr-x | do_replicate.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/do_replicate.sh b/do_replicate.sh new file mode 100755 index 0000000..d3b9cbe --- /dev/null +++ b/do_replicate.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +DEST_URL=$1 +SRC_POOL=$2 +DEST_POOL=$3 + +OLD_SNAP=$(ssh root@$DEST_URL "zfs list -t snapshot -o name $DEST_POOL | tail -n1" | cut -d "@" -f2) +NEW_SNAP=$(zfs list -t snapshot -o name $SRC_POOL | tail -n1 | cut -d "@" -f2) + +echo "Old snapshot: '$OLD_SNAP'" +echo "New snapshot: '$NEW_SNAP'" + +if [ "$OLD_SNAP" = "$NEW_SNAP" ]; then + echo "Up to date, nothing to do..." +else + zfs send -Rw -I "$SRC_POOL"@"$OLD_SNAP" "$SRC_POOL"@"$NEW_SNAP" -s | pv | ssh root@DEST_URL "zfs recv -Fvdu $DEST_POOL" +fi |