check that SRC drive contains all fstabs. Fix DST after disk sync.

This commit is contained in:
2021-04-30 15:50:09 +02:00
parent ec99a02d4f
commit 8879fe1812

View File

@@ -77,8 +77,6 @@
# TODO # TODO
# * Write about autofs configuration. # * Write about autofs configuration.
# * Log levels # * Log levels
# * Check existence of prepared fstab on source root partition for
# destination root partition, and enable it.
#%MAN_END% #%MAN_END%
# command line # command line
@@ -214,6 +212,25 @@ function check_block_device {
return 0 return 0
} }
# check that /etc/fstab.XXX exists in SRCR
function check_fstab {
local fstab
for f in "$SRCROOTLABEL" "$DSTROOTLABEL"; do
fstab="${AUTOFS_DIR}/$SRCROOTLABEL/etc/fstab.$f"
#log -n "======= check %s=%s " "$fstab" "$f"
if [[ ! -f "$fstab" ]]; then
log "Fatal: source or destination fstab (%s) not found" "$fstab"
return 1
fi
done
return 0
}
function fix_fstab {
local fstab="${AUTOFS_DIR}/$DSTROOTLABEL/etc/fstab"
echorun ln -f "$fstab.$DSTROOTLABEL" "$fstab"
}
# check if $1 is in array $2 ($2 is by reference) # check if $1 is in array $2 ($2 is by reference)
function in_array { function in_array {
local elt=$1 i local elt=$1 i
@@ -435,6 +452,8 @@ for ((i=0; i<${#LABELS[@]}; ++i)); do
echo echo
done | column -N DEV1,DEV2,LABEL1,LABEL2,FS1,FS2,SVALID\?,DVALID\?,ROOT -t -o " | " done | column -N DEV1,DEV2,LABEL1,LABEL2,FS1,FS2,SVALID\?,DVALID\?,ROOT -t -o " | "
check_fstab || exit 1
RSYNCOPTS="-axH --delete --delete-excluded" RSYNCOPTS="-axH --delete --delete-excluded"
FILTER=--filter="dir-merge .rsync-disk-copy" FILTER=--filter="dir-merge .rsync-disk-copy"
# copy loop # copy loop
@@ -456,6 +475,9 @@ for ((i=0; i<${#LABELS[@]}; ++i)); do
mariadb_maybe_stop mariadb_maybe_stop
# shellcheck disable=SC2086 # shellcheck disable=SC2086
echorun rsync "$FILTER" ${RSYNCOPTS} "$SRCPART" "$DSTPART" echorun rsync "$FILTER" ${RSYNCOPTS} "$SRCPART" "$DSTPART"
if [[ "$DSTROOTLABEL" == "${DSTLABELS[$i]}" ]]; then
fix_fstab
fi
fi fi
#log "" #log ""
done done