skip mtree if disabled or missing

This commit is contained in:
Jérémy Lecour 2023-01-13 13:30:57 +01:00 committed by Jérémy Lecour
parent e9cf39ad40
commit 46c012f5fc

View file

@ -43,6 +43,8 @@ LOCAL_BACKUP_DIR="/home/backup"
: "${LOCAL_TASKS:=1}"
# Enable/disable sync tasks (default: enabled)
: "${SYNC_TASKS:=1}"
# Enable/disable mtree (default: enabled)
: "${MTREE_ENABLED:=1}"
# Source paths can be customized
# Empty lines, and lines containing # or ; are ignored
@ -846,6 +848,10 @@ sync_tasks() {
echo "${RSYNC_INCLUDES}" | sed -e 's/\s*\(#\|;\).*//; /^\s*$/d' > "${rsync_includes_file}"
echo "${RSYNC_EXCLUDES}" | sed -e 's/\s*\(#\|;\).*//; /^\s*$/d' > "${rsync_excludes_file}"
if [ "${MTREE_ENABLED}" = "1" ]; then
mtree_bin=$(command -v mtree)
if [ -n "${mtree_bin}" ]; then
# Dump filesystem stats with mtree
log "SYNC_TASKS - start mtree"
@ -861,7 +867,7 @@ sync_tasks() {
mtree_file="/var/log/evobackup.$(basename "${line}").mtree"
temp_files+=("${mtree_file}")
mtree -x -c -p "${line}" -X "${mtree_excludes_file}" > "${mtree_file}"
${mtree_bin} -x -c -p "${line}" -X "${mtree_excludes_file}" > "${mtree_file}"
mtree_files+=("${mtree_file}")
done < "${rsync_includes_file}"
@ -870,7 +876,12 @@ sync_tasks() {
fi
log "SYNC_TASKS - stop mtree (files: ${mtree_files[*]})"
else
log "SYNC_TASKS - skip mtree (missing)"
fi
else
log "SYNC_TASKS - skip mtree (disabled)"
fi
rsync_bin=$(command -v rsync)
# Build the final Rsync command