Created
April 3, 2022 17:43
-
-
Save degaart/3c64b1f838a41fcb01b0ff299a8093c0 to your computer and use it in GitHub Desktop.
Send zfs dataset to another server as fast as possible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eou pipefail | |
SRC_DATASET="${1-}" | |
DST_HOST="${2-}" | |
DST_DATASET="${3-}" | |
MBUFFER_PORT=1024 | |
if [ "$DST_DATASET" = "" ]; then | |
echo "Usage: $0 <src-dataset> <dst-host> <dst_dataset>" | |
exit 1 | |
fi | |
ssh root@"$DST_HOST" "mbuffer -q -m2G -s256k -I${MBUFFER_PORT}|zfs receive -Fu ${DST_DATASET}" & | |
zfs destroy -r "${SRC_DATASET}@send" || true | |
zfs snap "${SRC_DATASET}@send" | |
zfs send -ec "${SRC_DATASET}@send"|mbuffer -s256k -m2G -O"${DST_HOST}:${MBUFFER_PORT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment