Skip to content

Instantly share code, notes, and snippets.

@i8degrees
Created April 14, 2024 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i8degrees/48bdaaec3534ececc696ec409fbce1e9 to your computer and use it in GitHub Desktop.
Save i8degrees/48bdaaec3534ececc696ec409fbce1e9 to your computer and use it in GitHub Desktop.
My completed ZFS pool replication script
#!/bin/sh
#
# zfs snapshot -r offsite2_fs1/boot-pool@migrate
# zfs snapshot -r offsite2_fs1/npool0@migrate
#
datasets=(`zfs list -r offsite2_fs1/boot-pool -o name -H`);
existing_pool="offsite2_fs1"
new_pool="offsite2_fs1.tmp"
buffer=() # inbound scratch
for dataset in "${datasets[@]}"; do
buffer+=("${dataset}@migrate\n")
#echo "zfs send -R \"${dataset}@migrate\" >> "/tmp/zfs.list.2"
done
#echo -e "${buffer[*]}"
echo "existing: ${existing_pool}"
echo "new: ${new_pool}"
#sed -i "s/${existing_pool}/${new_pool}/" "/tmp/zfs.list.2"
for dataset in "${datasets[@]}"; do
buffer=("" "zfs send -Rpv ${dataset}@migrate")
buffer+=("|" "zfs recv -dFu ${new_pool}/${dataset}")
echo -e "${buffer[*]}"
#echo "zfs send -R \"${dataset}@migrate\"
#echo "zfs send -R \"${dataset}@migrate\" | zfs recv -F ${new_pool}/${dataset}";
done
#echo -e "${buffer[*]}"
#zfs list -H -r offsite2_fs1 -o name > /tmp/zfs.list
#sed -i 's/offsite2_fs1/offsite2_fs1.tmp/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment