preserve recordsize, atime and relatime variables of datasets

This commit is contained in:
Milan Meduna 2021-01-08 12:34:54 +01:00
parent bd0862a9d7
commit 947211c1c3

View file

@ -28,6 +28,9 @@ DEST_SNAPS_CLEANED=$(echo "$DEST_SNAPS" | grep crypt | grep lxd | grep storage |
SOURCE_DEST_IDENTICAL_SNAPS=$(grep -Fxf <(echo "$SNAPS_CLEANED") <(echo "$DEST_SNAPS_CLEANED")) SOURCE_DEST_IDENTICAL_SNAPS=$(grep -Fxf <(echo "$SNAPS_CLEANED") <(echo "$DEST_SNAPS_CLEANED"))
SNAP_TO_SEND_FIRST=$(echo "$SOURCE_DEST_IDENTICAL_SNAPS" | tail -n1) SNAP_TO_SEND_FIRST=$(echo "$SOURCE_DEST_IDENTICAL_SNAPS" | tail -n1)
DATASET_VAR=$(echo "$DATASETS" | grep crypt | grep lxd | grep storage | grep containers | awk {'print $1'} | grep -E "$CONT_VAR"$) DATASET_VAR=$(echo "$DATASETS" | grep crypt | grep lxd | grep storage | grep containers | awk {'print $1'} | grep -E "$CONT_VAR"$)
DATASET_RECORDSIZE_VAR=$(zfs get recordsize -H -o value "$DATASET_VAR")
DATASET_ATIME_VAR=$(zfs get atime -H -o value "$DATASET_VAR")
DATASET_RELATIME_VAR=$(zfs get relatime -H -o value "$DATASET_VAR")
SNAP_TO_SEND_FIRST_FOR_LATER_CHECK=$(echo "$SNAP_TO_SEND_FIRST") SNAP_TO_SEND_FIRST_FOR_LATER_CHECK=$(echo "$SNAP_TO_SEND_FIRST")
IFS=" IFS="
@ -54,7 +57,7 @@ fi
echo "Sending first snapshot" echo "Sending first snapshot"
echo "Sending "$SNAP_TO_SEND_FIRST"" echo "Sending "$SNAP_TO_SEND_FIRST""
zfs send "$SNAP_TO_SEND_FIRST" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" zfs send "$SNAP_TO_SEND_FIRST" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"
echo "Sleep 2" echo "Sleep 2"
sleep 2 sleep 2
@ -74,7 +77,7 @@ done
echo "Sending second snapshot" echo "Sending second snapshot"
echo "Sending "$SNAP_TO_SEND_FIRST" to "$SNAP_TO_SEND_SECOND" with -I parameter" echo "Sending "$SNAP_TO_SEND_FIRST" to "$SNAP_TO_SEND_SECOND" with -I parameter"
zfs send -I "$SNAP_TO_SEND_FIRST" "$SNAP_TO_SEND_SECOND" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F zfs send -I "$SNAP_TO_SEND_FIRST" "$SNAP_TO_SEND_SECOND" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F
echo "Sleep 2" echo "Sleep 2"
sleep 2 sleep 2
@ -89,7 +92,7 @@ done
echo "Sending third snapshot" echo "Sending third snapshot"
echo "Sending "$SNAP_TO_SEND_SECOND" to "$SNAP_TO_SEND_THIRD"" echo "Sending "$SNAP_TO_SEND_SECOND" to "$SNAP_TO_SEND_THIRD""
zfs send -i "$SNAP_TO_SEND_SECOND" "$SNAP_TO_SEND_THIRD" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F zfs send -i "$SNAP_TO_SEND_SECOND" "$SNAP_TO_SEND_THIRD" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F
echo "Sleep 2" echo "Sleep 2"
sleep 2 sleep 2
@ -104,7 +107,7 @@ done
echo "Sending fourth snapshot" echo "Sending fourth snapshot"
echo "Sending "$SNAP_TO_SEND_THIRD" to "$SNAP_TO_SEND_FOURTH"" echo "Sending "$SNAP_TO_SEND_THIRD" to "$SNAP_TO_SEND_FOURTH""
zfs send -i "$SNAP_TO_SEND_THIRD" "$SNAP_TO_SEND_FOURTH" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F zfs send -i "$SNAP_TO_SEND_THIRD" "$SNAP_TO_SEND_FOURTH" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F
echo "Sleep 2" echo "Sleep 2"
sleep 2 sleep 2
@ -125,7 +128,7 @@ done
echo "Sending fifth snapshot" echo "Sending fifth snapshot"
echo "Sending "$SNAP_TO_SEND_FOURTH" to "$SNAP_TO_SEND_FIFTH"" echo "Sending "$SNAP_TO_SEND_FOURTH" to "$SNAP_TO_SEND_FIFTH""
zfs send -i "$SNAP_TO_SEND_FOURTH" "$SNAP_TO_SEND_FIFTH" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F zfs send -i "$SNAP_TO_SEND_FOURTH" "$SNAP_TO_SEND_FIFTH" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv -o recordsize="$DATASET_RECORDSIZE_VAR" -o atime="$DATASET_ATIME_VAR" -o relatime="$DATASET_RELATIME_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" -F
if [ $bionic_checker == bionic ] if [ $bionic_checker == bionic ]
then then