Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
31309f2576 | |||
db8e656613 | |||
9725a09c06 | |||
bd300718e7 | |||
cfd15aca3b | |||
4b541698df | |||
d5886da0a4 | |||
784cda10eb | |||
2adcac027b |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.vscode/
|
26
btrbk-cron
26
btrbk-cron
@ -5,6 +5,12 @@ LOCKFILE=/run/btrbk/btrbk.lock
|
|||||||
LOGFILE=$(mktemp)
|
LOGFILE=$(mktemp)
|
||||||
trap 'rm -f -- "${LOGFILE}"' EXIT
|
trap 'rm -f -- "${LOGFILE}"' EXIT
|
||||||
|
|
||||||
|
# check for superpowers
|
||||||
|
if [[ "${EUID}" -ne 0 ]] ; then
|
||||||
|
echo "Please run me as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "---" | tee -a "${LOGFILE}"
|
echo "---" | tee -a "${LOGFILE}"
|
||||||
echo "Start btrbk-cron: $(date||true)" | tee -a "${LOGFILE}"
|
echo "Start btrbk-cron: $(date||true)" | tee -a "${LOGFILE}"
|
||||||
|
|
||||||
@ -31,13 +37,21 @@ else
|
|||||||
echo "Info: Healthchecks disabled"
|
echo "Info: Healthchecks disabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# lockfile check
|
||||||
if [[ -f "${LOCKFILE}" ]] ; then
|
if [[ -f "${LOCKFILE}" ]] ; then
|
||||||
echo "Another instance is still running" | tee -a "${LOGFILE}"
|
# check if stale lockfile
|
||||||
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
if [[ $(pgrep --exact --count btrbk || true) -eq 0 ]] ; then
|
||||||
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log"
|
echo "Removing stale lock file: ${LOCKFILE}"
|
||||||
|
rm "${LOCKFILE}"
|
||||||
|
else
|
||||||
|
# another instance is really running, we exit
|
||||||
|
echo "Another instance is still running" | tee -a "${LOGFILE}"
|
||||||
|
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
||||||
|
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log"
|
||||||
|
fi
|
||||||
|
rm -f -- "${LOGFILE}"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
rm -f -- "${LOGFILE}"
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOST=$(grep -E '^[\ \t]*target[\ \t]+send-receive' /etc/btrbk/btrbk.conf)
|
HOST=$(grep -E '^[\ \t]*target[\ \t]+send-receive' /etc/btrbk/btrbk.conf)
|
||||||
@ -71,7 +85,7 @@ if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
|||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
echo "healthcheck notified! (start)" | tee -a "${LOGFILE}"
|
echo "healthcheck notified! (start)" | tee -a "${LOGFILE}"
|
||||||
(nice -n 19 /usr/bin/ionice -c idle /usr/bin/btrbk -v --progress run >> "${LOGFILE}" ; ) 2>&1
|
(nice -n 19 /usr/bin/ionice -c idle /usr/bin/btrbk -v --progress run 2>&1 || true) | tee -a "${LOGFILE}" 2>&1
|
||||||
ret=$?
|
ret=$?
|
||||||
if [[ "${ret}" -eq "0" ]]; then
|
if [[ "${ret}" -eq "0" ]]; then
|
||||||
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
||||||
|
19
debian/changelog
vendored
19
debian/changelog
vendored
@ -1,3 +1,22 @@
|
|||||||
|
btrbk-cron (0.4.2) stable; urgency=medium
|
||||||
|
|
||||||
|
* gather all logs
|
||||||
|
|
||||||
|
-- Paolo Asperti <paolo@asperti.com> Tue, 22 Oct 2024 11:21:43 +0200
|
||||||
|
|
||||||
|
btrbk-cron (0.4.1) stable; urgency=medium
|
||||||
|
|
||||||
|
* fix error redir
|
||||||
|
|
||||||
|
-- Paolo Asperti <paolo@asperti.com> Wed, 16 Oct 2024 11:56:39 +0200
|
||||||
|
|
||||||
|
btrbk-cron (0.4) stable; urgency=medium
|
||||||
|
|
||||||
|
* stale lockfile check
|
||||||
|
* require to run as root
|
||||||
|
|
||||||
|
-- Paolo Asperti <paolo@asperti.com> Tue, 15 Oct 2024 09:23:11 +0200
|
||||||
|
|
||||||
btrbk-cron (0.3) stable; urgency=medium
|
btrbk-cron (0.3) stable; urgency=medium
|
||||||
|
|
||||||
* clean exit if lockfile present
|
* clean exit if lockfile present
|
||||||
|
Loading…
Reference in New Issue
Block a user