Clean up bash shell code and add proper ENCRYPTION support

- check for invalid encryption setting
- switch from none to keyfile type (without password)
- error for no password for repokey or authentication type encryption
- update init and print out the key file data
This commit is contained in:
Clemens Schwaighofer
2025-12-01 16:53:50 +09:00
parent 297c745df7
commit 7e4dc8d500
13 changed files with 206 additions and 147 deletions

View File

@@ -1,25 +1,28 @@
#!/usr/bin/env bash
# allow variables in printf format string
# shellcheck disable=SC2059
if [ -z "${MODULE}" ]; then
echo "Script cannot be run on its own";
exit 1;
fi;
if [ ${INFO} -eq 1 ]; then
if [ "${INFO}" -eq 1 ]; then
printf "${PRINTF_SUB_BLOCK}" "INFO" "$(date +'%F %T')" "${MODULE}";
# show command on debug or dry run
if [ ${DEBUG} -eq 1 ] || [ ${DRYRUN} -eq 1 ]; then
if [ "${DEBUG}" -eq 1 ] || [ "${DRYRUN}" -eq 1 ]; then
echo "export BORG_BASE_DIR=\"${BASE_FOLDER}\";${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY}";
fi;
# run info command if not a dry drun
if [ ${DRYRUN} -eq 0 ]; then
${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY};
if [ "${DRYRUN}" -eq 0 ]; then
${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}";
fi;
if [ "${MODULE}" = "files" ]; then
if [ $FOLDER_OK -eq 1 ]; then
if [ "${FOLDER_OK}" -eq 1 ]; then
echo "--- [Run command]:";
#IFS="#";
echo "export BORG_BASE_DIR=\"${BASE_FOLDER}\";${COMMAND} "${FOLDERS_Q[*]};
echo "export BORG_BASE_DIR=\"${BASE_FOLDER}\";${COMMAND} ${FOLDERS_Q[*]}";
else
echo "[!] No folders where set for the backup";
fi;