Add scripts for zfs send and recv for making full clones.

I most often need to make full clones when doing zfs send or recv so this writes down all the flags I prefer to use in a script so I do not forget them.
This commit is contained in:
Tom Alexander 2023-05-01 22:20:55 -04:00
parent 34a1ed73eb
commit a4e75f98d7
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
#
# A zfs-send alias that creates a perfect clone with good defaults.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# -s if the stream is interrupted, save the partial stream. The stream can then be resumed by doing a zfs send -t token where token is the receive_resume_token prop on the dataset we received into.
# -u Do not mount the filesystem we are receiving. We can always mount afterwards but this avoids issues with streams with mountpoints to places like /
zfs recv -s -u
# To delete an interrupted recv, run `zfs receive -A dataset`

View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# A zfs-send alias that creates a perfect clone with good defaults.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# TODO: Do we want --backup ?
# We get --props automatically from --replicate
zfs send --compressed --replicate --large-block --embed --verbose "${@}"
# On zfs recv side, may want to pass `-s` to make the stream resumable.
# If the data is encrypted and you DONT want to decrypt it, pass the --raw flag on the send side
# You may need to remove --embed above for encrypted datasets (maybe only with --raw flag? very unsure)
# For unencrypted datasets, --raw will be equivalent to -Lec (large block, embed, compressed)

View File

@ -1,3 +1,16 @@
- name: Install scripts
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0755
owner: root
group: wheel
loop:
- src: "zfs_clone_send.bash"
dest: /usr/local/bin/zfs_clone_send
- src: "zfs_clone_recv.bash"
dest: /usr/local/bin/zfs_clone_recv
- import_tasks: tasks/freebsd.yaml
when: 'os_flavor == "freebsd"'