mirror of
https://asciireactor.com/o4data/zfs-backup.git
synced 2024-11-23 11:55:06 +00:00
Updates.
This commit is contained in:
parent
d4598beff5
commit
706aab7d4f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
datasets.txt
|
||||
nodes.txt
|
||||
old-snapshot.txt
|
||||
sendnodes.tmp
|
23
backup.sh
23
backup.sh
@ -17,9 +17,10 @@ datasets_file="datasets.txt"
|
||||
if [ ! -f $nodes_file ]; then echo "No nodes specified."; exit 2; fi
|
||||
if [ ! -f $datasets_file ]; then echo "No datasets specified."; exit 3; fi
|
||||
|
||||
ZFS_SEND_OPTS="-R"
|
||||
ZFS_SEND_OPTS="-vpRLe"
|
||||
ZFS_SNAPSHOT_OPTS="-r"
|
||||
ZFS_RECV_OPTS="-svu"
|
||||
SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa"
|
||||
|
||||
read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file
|
||||
case $SEND_COMPRESSED in
|
||||
@ -27,7 +28,7 @@ case $SEND_COMPRESSED in
|
||||
esac
|
||||
|
||||
ORIGIN_PERMS="send,snapshot,hold"
|
||||
MIRROR_PERMS="compression,receive,create,mount,mountpoint"
|
||||
MIRROR_PERMS="compression,receive,create,mount,mountpoint,readonly,jailed"
|
||||
|
||||
SEND_DATASETS=""
|
||||
SNAPSHOT_DATASETS=""
|
||||
@ -70,12 +71,12 @@ list_remote_datasets() {
|
||||
esac
|
||||
fi
|
||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||
echo ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr\
|
||||
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr\
|
||||
"sh -c 'for dataset in $SEND_DATASETS;
|
||||
do zfs list -H $zroot\$dataset;
|
||||
done'"
|
||||
else
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
"sh -c 'for dataset in $SEND_DATASETS;
|
||||
do zfs list -H $zroot\$dataset;
|
||||
done';"
|
||||
@ -96,7 +97,7 @@ get_latest_remote_snapshot()
|
||||
*) zroot="$zroot/" ;;
|
||||
esac
|
||||
fi
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
"zfs list -t snapshot $zroot\$dataset |
|
||||
tail -n1|cut -d'@' -f2|cut -d' ' -f 1"
|
||||
}
|
||||
@ -123,12 +124,12 @@ zfs_allow_mirrors()
|
||||
esac
|
||||
fi
|
||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||
echo ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
"for dataset in $SEND_DATASETS; do
|
||||
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
|
||||
done"
|
||||
else
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
"for dataset in $SEND_DATASETS; do
|
||||
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
|
||||
done"
|
||||
@ -162,11 +163,11 @@ send_latest()
|
||||
origin_snapshot=`get_latest_snapshot $dataset`
|
||||
if [ $BG_TEST_MODE = "TRUE" ]; then
|
||||
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
zfs recv $ZFS_RECV_OPTS $zroot$dataset
|
||||
else
|
||||
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port \
|
||||
$user@$addr \
|
||||
zfs recv $ZFS_RECV_OPTS $zroot$dataset
|
||||
fi
|
||||
@ -191,13 +192,13 @@ send_increment()
|
||||
echo zfs send $ZFS_SEND_OPTS \
|
||||
-i $dataset@$remote_snapshot \
|
||||
$dataset@$origin_snapshot \| \
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
zfs recv $ZFS_RECV_OPTS $zroot$dataset
|
||||
else
|
||||
zfs send $ZFS_SEND_OPTS \
|
||||
-i $dataset@$remote_snapshot \
|
||||
$dataset@$origin_snapshot |
|
||||
ssh -i ~/.ssh/id_rsa -o port=$ssh_port $user@$addr \
|
||||
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
|
||||
zfs recv $ZFS_RECV_OPTS $zroot$dataset
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user