Compare commits

..

9 Commits
0.3 ... master

Author SHA1 Message Date
31309f2576
version bump
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-22 11:21:55 +02:00
db8e656613
gather all logs 2024-10-22 11:21:13 +02:00
9725a09c06
version bump
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-16 11:57:01 +02:00
bd300718e7
fix error redir 2024-10-16 11:56:23 +02:00
cfd15aca3b
version bump
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-15 09:23:30 +02:00
4b541698df
ignored vscode dir 2024-10-15 09:21:25 +02:00
d5886da0a4
fix exact grep 2024-10-15 09:20:15 +02:00
784cda10eb
run as root 2024-10-15 09:13:10 +02:00
2adcac027b
stale lockfile check 2024-10-15 08:16:57 +02:00
3 changed files with 40 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vscode/

View File

@ -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,7 +37,14 @@ else
echo "Info: Healthchecks disabled" echo "Info: Healthchecks disabled"
fi fi
# lockfile check
if [[ -f "${LOCKFILE}" ]] ; then if [[ -f "${LOCKFILE}" ]] ; then
# check if stale lockfile
if [[ $(pgrep --exact --count btrbk || true) -eq 0 ]] ; then
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}" echo "Another instance is still running" | tee -a "${LOGFILE}"
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log" curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log"
@ -39,6 +52,7 @@ if [[ -f "${LOCKFILE}" ]] ; then
rm -f -- "${LOGFILE}" rm -f -- "${LOGFILE}"
exit 0 exit 0
fi 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)
# TODO: support for dashes in hostname and IPv6 ("[2001:db8::7]") # TODO: support for dashes in hostname and IPv6 ("[2001:db8::7]")
@ -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
View File

@ -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