Created
March 3, 2023 03:21
-
-
Save mshroyer/95576e262d8f54fcd15f26ee62fe6c19 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
# Updates a replica of the ds1 dataset. | |
# | |
# Ideally we'd use bookmarks instead of snapshots to track the starting point | |
# of incremental sends, but OpenZFS 2.0.0 doesn't support sending multiple | |
# datasets from the same bookmark (and I don't feel like rewriting all of the | |
# functionality of zfs send -R). | |
# | |
# Usage: update_ds1_replica <dest_pool> | |
set -e | |
SRC_POOL=tank | |
DS=ds1 | |
dest_pool=$1 | |
if [ -z "$dest_pool" ]; then | |
>&2 echo "Usage: update_ds1_replica <dest_pool>" | |
exit 1 | |
fi | |
if ! zpool list $dest_pool >/dev/null; then | |
>&2 echo "Destination pool ${dest_pool} not available" | |
exit 1 | |
fi | |
snapshot="${SRC_POOL}/${DS}@${dest_pool}" | |
snapshot_new="${snapshot}-new" | |
zfs snapshot -r $snapshot_new | |
zfs send -RwI $snapshot $snapshot_new | pv | zfs recv -F "${dest_pool}/${DS}" | |
zfs destroy -R $snapshot | |
zfs rename -r $snapshot_new $snapshot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment