Add borg check and rename options

Because we added borg check functionality, some of the Options have been
renamed:
-C -> -V
-E -> -e (as it is a sub)

-C: check
-y: --verify-data
-p: prefix or glob for check

Internal variables with CHECK have been renamed or changed to VERIFY

Borg -C without any extra parameters is equal to borg check.
-y adds the --verify-data and -p is a mix of the -P and -a options. If
there is a "*" in the option then -a will be used, else -P

Note that repair command has to be run manually. Run -C with -v
(verbose) to see the repair command structure.

borg check can take a long time on very large repositories.
This commit is contained in:
Clemens Schwaighofer
2022-04-18 15:30:03 +09:00
parent b5ead9a2e1
commit 2ae05f5302
9 changed files with 190 additions and 103 deletions

View File

@@ -5,12 +5,9 @@
# config override set in borg.backup.mysql.settings
# if run as mysql user, be sure user is in the backup group
# Run -I first to initialize repository
# There are no automatic repository checks unless -C is given
# set last edit date + time
MODULE="mysql"
MODULE_VERSION="1.1.0";
MODULE_VERSION="1.1.1";
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
@@ -21,11 +18,11 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
INCLUDE_FILE="borg.backup.mysql.include";
EXCLUDE_FILE="borg.backup.mysql.exclude";
SCHEMA_ONLY_FILE="borg.backup.mysql.schema-only";
# init check file
BACKUP_INIT_CHECK="borg.backup.mysql.init";
# init verify file
BACKUP_INIT_VERIFY="borg.backup.mysql.init";
# check valid data
. "${DIR}/borg.backup.functions.check.sh";
# verify valid data
. "${DIR}/borg.backup.functions.verify.sh";
# if info print info and then abort run
. "${DIR}/borg.backup.functions.info.sh";
@@ -50,10 +47,10 @@ if [ ! -f "${MYSQL_CMD}" ]; then
. "${DIR}/borg.backup.functions.close.sh" 1;
exit 1;
fi;
# check that the user can actually do, else abort here
# verify that the user can actually do, else abort here
# note: this is the only way to not error
_MYSQL_CHECK=$(mysqladmin ${MYSQL_DB_CONFIG_PARAM} ping 2>&1);
_MYSQL_OK=$(echo "${_MYSQL_CHECK}" | grep "is alive");
_MYSQL_VERIFY=$(mysqladmin ${MYSQL_DB_CONFIG_PARAM} ping 2>&1);
_MYSQL_OK=$(echo "${_MYSQL_VERIFY}" | grep "is alive");
if [ -z "${_MYSQL_OK}" ]; then
echo "[! $(date +'%F %T')] Current user has no access right to mysql database";
. "${DIR}/borg.backup.functions.close.sh" 1;