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