borg-backup-nc.sh: add support for symlinks

This commit is contained in:
Christoph 2024-07-02 10:35:58 +02:00
parent 308afabc03
commit 07ed51f9ad

View File

@ -293,6 +293,20 @@ BORG_LOG_FILE="${BORG_LOG_DIR}/${backup_date}.log"
[[ -z "${BACKUP_OTHER_DIRECTORIES}" ]] && BACKUP_OTHER_DIRECTORIES="${DEFAULT_BACKUP_OTHER_DIRECTORIES}"
# By default: Borg won't follow symlinks
#
BORG_BACKUP_DIRS=""
for _dir in $BACKUP_OTHER_DIRECTORIES ; do
if [[ -h "${_dir}" ]] ; then
BORG_BACKUP_DIRS="$BORG_BACKUP_DIRS $(realpath "${_dir}")"
fi
BORG_BACKUP_DIRS="$BORG_BACKUP_DIRS ${_dir}"
done
# remove leading whitespace characters
#
BORG_BACKUP_DIRS="${BORG_BACKUP_DIRS#"${BORG_BACKUP_DIRS%%[![:space:]]*}"}"
BORG_URL="ssh://${SSH_USER}@${BORG_HOST}:${SSH_PORT}${BORG_REPO}"
@ -538,7 +552,7 @@ borg create \\
${NC_DB_BACKUP_DIR} \\
${NC_PATH} \\
${NC_DATA_DIR} \\
${BACKUP_OTHER_DIRECTORIES}
${BORG_BACKUP_DIRS}
EOF
borg create \
@ -559,7 +573,7 @@ borg create \
${NC_DB_BACKUP_DIR} \
${NC_PATH} \
${NC_DATA_DIR} \
${BACKUP_OTHER_DIRECTORIES} \
${BORG_BACKUP_DIRS} \
> ${log_file} 2>&1