Skip to content

Instantly share code, notes, and snippets.

@segrax
Created December 1, 2019 22:09
Show Gist options
  • Save segrax/b56788db7a9feddd795915dd45d41093 to your computer and use it in GitHub Desktop.
Save segrax/b56788db7a9feddd795915dd45d41093 to your computer and use it in GitHub Desktop.
Check a remote server for a zfs send resume token, and resume transfer if found
#!/bin/sh
#
# ZFS Archive Resume Script
# Robert Crossfield
#
# Check for a zfs send resume token, and resume the transfer if found
# 26-05-2019
#
HOST=me@mydomain.com
PORT=12345
MOUNT=MyZpool/Mount
TOKEN=`ssh -q $HOST -p $PORT zfs get all $MOUNT | awk '{for (I=1;I<=NF;I++) if ($I == "receive_resume_token") {print $(I+1)};}'`
if [ ! "$TOKEN" ];then
echo "No token found"
exit
else
zfs send -t $TOKEN | pv | ssh $HOST -p $PORT zfs recv -F -s $MOUNT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment