Compare commits
7 Commits
master
...
refactor/T
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03925562ff | ||
|
|
783bf2adb9 | ||
|
|
dd2a85f5d6 | ||
|
|
2e5f0648f1 | ||
|
|
acd5d369eb | ||
|
|
de9d5d3588 | ||
|
|
8407defe4f |
@@ -31,16 +31,16 @@ MODULE_LIST="file gitea mysql pgsql zabbix"
|
|||||||
# -n for dry run test
|
# -n for dry run test
|
||||||
while getopts ":c:snd" opt; do
|
while getopts ":c:snd" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
c|config)
|
c) # config
|
||||||
BASE_FOLDER=${OPTARG};
|
BASE_FOLDER=${OPTARG};
|
||||||
;;
|
;;
|
||||||
s|nosudo)
|
s) # nosudo
|
||||||
PGSQL_SUDO=0;
|
PGSQL_SUDO=0;
|
||||||
;;
|
;;
|
||||||
d|debug)
|
d) # debug
|
||||||
DEBUG=1;
|
DEBUG=1;
|
||||||
;;
|
;;
|
||||||
n|dryrun)
|
n) # dryrun
|
||||||
DRYRUN=1;
|
DRYRUN=1;
|
||||||
;;
|
;;
|
||||||
:)
|
:)
|
||||||
@@ -64,6 +64,7 @@ if [ ! -f "${BASE_FOLDER}${SETTINGS_FILE}" ]; then
|
|||||||
echo "Could not find: ${BASE_FOLDER}${SETTINGS_FILE}";
|
echo "Could not find: ${BASE_FOLDER}${SETTINGS_FILE}";
|
||||||
exit;
|
exit;
|
||||||
fi;
|
fi;
|
||||||
|
# shellcheck source="borg.backup.settings"
|
||||||
. "${BASE_FOLDER}${SETTINGS_FILE}";
|
. "${BASE_FOLDER}${SETTINGS_FILE}";
|
||||||
|
|
||||||
if [ -n "${TARGET_BORG_PATH}" ]; then
|
if [ -n "${TARGET_BORG_PATH}" ]; then
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ fi;
|
|||||||
|
|
||||||
# compact (only if BORG COMPACT is set)
|
# compact (only if BORG COMPACT is set)
|
||||||
# only for borg 1.2
|
# only for borg 1.2
|
||||||
|
if [ "$(version "$BORG_VERSION")" -ge "$(version "1.2.0")" ]; then
|
||||||
if [ "$(version "$BORG_VERSION")" -ge "$(version "1.2.0")" ]; then
|
if [ "$(version "$BORG_VERSION")" -ge "$(version "1.2.0")" ]; then
|
||||||
RUN_COMPACT=0;
|
RUN_COMPACT=0;
|
||||||
if [ $# -ge 1 ] && [ "$1" = "auto" ]; then
|
if [ $# -ge 1 ] && [ "$1" = "auto" ]; then
|
||||||
@@ -21,10 +22,13 @@ if [ "$(version "$BORG_VERSION")" -ge "$(version "1.2.0")" ]; then
|
|||||||
fi;
|
fi;
|
||||||
# get current date timestmap
|
# get current date timestmap
|
||||||
CURRENT_DATE=$(date +%s);
|
CURRENT_DATE=$(date +%s);
|
||||||
|
if [ "${COMPACT_INTERVAL}" -eq 1 ]; then
|
||||||
if [ "${COMPACT_INTERVAL}" -eq 1 ]; then
|
if [ "${COMPACT_INTERVAL}" -eq 1 ]; then
|
||||||
RUN_COMPACT=1;
|
RUN_COMPACT=1;
|
||||||
# set new compact time here
|
# set new compact time here
|
||||||
echo "${CURRENT_DATE}" > "${BASE_FOLDER}${BACKUP_COMPACT_FILE}";
|
echo "${CURRENT_DATE}" > "${BASE_FOLDER}${BACKUP_COMPACT_FILE}";
|
||||||
|
elif [ "${COMPACT_INTERVAL}" -gt 1 ]; then
|
||||||
|
echo "${CURRENT_DATE}" > "${BASE_FOLDER}${BACKUP_COMPACT_FILE}";
|
||||||
elif [ "${COMPACT_INTERVAL}" -gt 1 ]; then
|
elif [ "${COMPACT_INTERVAL}" -gt 1 ]; then
|
||||||
# else load last timestamp and check if today - last time stamp > days
|
# else load last timestamp and check if today - last time stamp > days
|
||||||
if [ -z "${LAST_COMPACT_DATE}" ]; then
|
if [ -z "${LAST_COMPACT_DATE}" ]; then
|
||||||
@@ -48,6 +52,7 @@ if [ "$(version "$BORG_VERSION")" -ge "$(version "1.2.0")" ]; then
|
|||||||
if [ "${RUN_COMPACT}" -eq 1 ]; then
|
if [ "${RUN_COMPACT}" -eq 1 ]; then
|
||||||
# reset to normal IFS, so command works here
|
# reset to normal IFS, so command works here
|
||||||
IFS=${_IFS};
|
IFS=${_IFS};
|
||||||
|
# shellcheck disable=SC2059
|
||||||
printf "${PRINTF_SUB_BLOCK}" "COMPACT" "$(date +'%F %T')" "${MODULE}";
|
printf "${PRINTF_SUB_BLOCK}" "COMPACT" "$(date +'%F %T')" "${MODULE}";
|
||||||
BORG_COMPACT="${BORG_COMMAND} compact ${OPT_REMOTE} -v ${OPT_PROGRESS} ${REPOSITORY}";
|
BORG_COMPACT="${BORG_COMMAND} compact ${OPT_REMOTE} -v ${OPT_PROGRESS} ${REPOSITORY}";
|
||||||
if [ "${DEBUG}" -eq 1 ]; then
|
if [ "${DEBUG}" -eq 1 ]; then
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ if [ ! -f "${ZABBIX_DUMP_BIN}" ]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
# -i (ignore)/ -f (backup)
|
# -i (ignore)/ -f (backup)
|
||||||
if [ ! -z "${ZABBIX_UNKNOWN_TABLES}" ]; then
|
if [ -n "${ZABBIX_UNKNOWN_TABLES}" ]; then
|
||||||
OPT_ZABBIX_UNKNOWN_TABLES="-f";
|
OPT_ZABBIX_UNKNOWN_TABLES="-f";
|
||||||
else
|
else
|
||||||
OPT_ZABBIX_UNKNOWN_TABLES="-i";
|
OPT_ZABBIX_UNKNOWN_TABLES="-i";
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ if [ ${UMOUNT} -eq 0 ]; then
|
|||||||
. ${BASE_FOLDER}${SETTINGS_FILE}
|
. ${BASE_FOLDER}${SETTINGS_FILE}
|
||||||
# set the borg backup file base on the settings data
|
# set the borg backup file base on the settings data
|
||||||
# if we have user/host then we build the ssh command
|
# if we have user/host then we build the ssh command
|
||||||
if [ ! -z "${TARGET_USER}" ] && [ ! -z "${TARGET_HOST}" ]; then
|
if [ -n "${TARGET_USER}" ] && [ -n "${TARGET_HOST}" ]; then
|
||||||
TARGET_SERVER=${TARGET_USER}"@"${TARGET_HOST}":";
|
TARGET_SERVER=${TARGET_USER}"@"${TARGET_HOST}":";
|
||||||
fi;
|
fi;
|
||||||
REPOSITORY=${TARGET_SERVER}${TARGET_FOLDER}${BACKUP_FILE};
|
REPOSITORY=${TARGET_SERVER}${TARGET_FOLDER}${BACKUP_FILE};
|
||||||
@@ -90,7 +90,7 @@ if [ ${UMOUNT} -eq 0 ]; then
|
|||||||
|
|
||||||
# check that the repostiory exists
|
# check that the repostiory exists
|
||||||
REPOSITORY_OK=0;
|
REPOSITORY_OK=0;
|
||||||
if [ ! -z "${TARGET_SERVER}" ]; then
|
if [ -n "${TARGET_SERVER}" ]; then
|
||||||
# remove trailing : for this
|
# remove trailing : for this
|
||||||
TARGET_SERVER=${TARGET_SERVER/:};
|
TARGET_SERVER=${TARGET_SERVER/:};
|
||||||
# use ssh command to check remote existense
|
# use ssh command to check remote existense
|
||||||
|
|||||||
Reference in New Issue
Block a user