Add a script to resume a zfs send/recv.

This commit is contained in:
Tom Alexander 2025-01-12 19:55:15 -05:00
parent 477637ae62
commit 8b1e76d9d7
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 25 additions and 0 deletions

View File

@ -17,6 +17,13 @@ let
(old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
zfs_clone_resume =
(pkgs.writeScriptBin "zfs_clone_resume" (builtins.readFile ./files/zfs_clone_resume.bash))
.overrideAttrs
(old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
in
{
@ -35,5 +42,6 @@ in
environment.systemPackages = with pkgs; [
zfs_clone_send
zfs_clone_recv
zfs_clone_resume
];
}

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Resume a zfs send.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function main {
local hst="$1"
local dst="$2"
local token
token=$(zfs get -H -o value receive_resume_token "$dst")
ssh "$hst" doas zfs send --verbose -t "$token" | doas zfs recv -s "$dst"
}
main "${@}"