#!/bin/ash

# usage: borg [common options] break-lock [options] [REPOSITORY]

# Check archives for consistency

# check arguments:
#   --progress    Display progress for each file as it is checked
#   --repair      Attempt to repair any inconsistencies found (experimental and
#                 only for interactive use)
#   --only CHECK  Run a particular consistency check (repository, archives,
#                 data, or extract) instead of configured checks; can specify
#                 flag multiple times
#   -h, --help    Show this help message and exit

exec_time=$(date)

if [ ! -f /etc/borgmatic.d/borg_check_running.flg ]
then
    /usr/bin/flock /etc/borgmatic.lock borgmatic --log-file /borg_logs/borgmatic.log --log-file-verbosity 2 --verbosity 2 --monitoring-verbosity 1 create --progress --stats -c /etc/borgmatic.d/jobs/"$1" 2>&1
else
    echo "[$exec_time] Borgmatic DB Check in progress"
    exit 1
fi





