mirror of
https://github.com/edv-pi/pbs-client-docker.git
synced 2025-04-20 07:52:56 +02:00
Fix lastrunfile logic and add lastbackup helper script.
This commit is contained in:
parent
f5f1a04d97
commit
aa90a87bc9
@ -41,3 +41,6 @@ RUN touch etc/s6-overlay/s6-rc.d/user/contents.d/backup
|
|||||||
|
|
||||||
COPY ./src/s6-services/cron-backup /etc/s6-overlay/s6-rc.d/cron-backup
|
COPY ./src/s6-services/cron-backup /etc/s6-overlay/s6-rc.d/cron-backup
|
||||||
RUN touch etc/s6-overlay/s6-rc.d/user/contents.d/cron-backup
|
RUN touch etc/s6-overlay/s6-rc.d/user/contents.d/cron-backup
|
||||||
|
|
||||||
|
COPY ./src/helper_scripts/* /usr/local/sbin/
|
||||||
|
RUN chmod +x /usr/local/sbin/*
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
find . -type f \( -name "*.sh" -o -name "up" -o -name "run*" \) -exec dos2unix {} \;
|
find . -type f \( -name "*.sh" -o -name "up" -o -name "run*" \) -exec dos2unix {} \;
|
||||||
|
find ./src/helper_scripts -type f -exec dos2unix {} \;
|
||||||
find . -type f | xargs git update-index --chmod=+x
|
find . -type f | xargs git update-index --chmod=+x
|
||||||
|
12
docker/src/helper_scripts/lastbackup
Normal file
12
docker/src/helper_scripts/lastbackup
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/with-contenv bash
|
||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
lastrunfile="/tmp/pbs_client_lastrun"
|
||||||
|
|
||||||
|
# First run touches the file. Backups will set the date.
|
||||||
|
# -s checks if the file exists and is not empty.
|
||||||
|
if [ -s "$lastrunfile" ]; then
|
||||||
|
cat "$lastrunfile"
|
||||||
|
else
|
||||||
|
echo "The first backup since container start has not happened yet."
|
||||||
|
fi
|
@ -67,6 +67,9 @@ if [ "$CRON_BACKUP_ONLY" = "0" ] || [ -e "${lastrunfile}" ]; then
|
|||||||
${BACKUPCMD} 2>&1
|
${BACKUPCMD} 2>&1
|
||||||
BACKUP_EXIT_CODE=$?
|
BACKUP_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# First run touches the file. Backups will set the date.
|
||||||
|
echo "$(date +"%Y-%m-%d %H:%M:%S")" > "${lastrunfile}"
|
||||||
|
|
||||||
if [ -n "$HEALTHCHECKSURL" ]; then
|
if [ -n "$HEALTHCHECKSURL" ]; then
|
||||||
# We pipe the exit code to healthchecks, if it isn't zero, a warning will fire.
|
# We pipe the exit code to healthchecks, if it isn't zero, a warning will fire.
|
||||||
curl -fsS -m 10 --retry 5 ${HEALTHCHECKSURL}/${BACKUP_EXIT_CODE}
|
curl -fsS -m 10 --retry 5 ${HEALTHCHECKSURL}/${BACKUP_EXIT_CODE}
|
||||||
@ -79,4 +82,5 @@ fi
|
|||||||
|
|
||||||
# Set this so backups always happen after the first run via CRON given logic above.
|
# Set this so backups always happen after the first run via CRON given logic above.
|
||||||
# The date may also be useful for something like a health check if I write it...
|
# The date may also be useful for something like a health check if I write it...
|
||||||
echo "$(date +"%Y-%m-%d %H:%M:%S")" > /tmp/pbs_client_lastrun
|
# First run touches the file. Backups will set the date.
|
||||||
|
touch "${lastrunfile}"
|
Loading…
Reference in New Issue
Block a user