backup-bot-two/entrypoint.sh

31 lines
826 B
Bash
Raw Permalink Normal View History

#!/bin/sh
2023-09-07 23:48:09 +00:00
set -e -o pipefail
2024-01-16 18:27:58 +00:00
apk add --upgrade --no-cache restic bash python3 py3-pip py3-click py3-docker-py py3-json-logger curl
2023-09-06 23:41:03 +00:00
2023-09-07 11:10:10 +00:00
# Todo use requirements file with specific versions
2023-12-19 00:16:12 +00:00
pip install --break-system-packages resticpy==1.0.2
cron_schedule="${CRON_SCHEDULE:?CRON_SCHEDULE not set}"
2024-01-16 18:27:58 +00:00
if [ -n "$PUSH_URL_START" ]
then
push_start_notification="curl -s '$PUSH_URL_START' &&"
fi
if [ -n "$PUSH_URL_FAIL" ]
2024-01-16 18:27:58 +00:00
then
push_fail_notification="|| curl -s '$PUSH_URL_FAIL'"
2024-01-16 18:27:58 +00:00
fi
if [ -n "$PUSH_URL_SUCCESS" ]
2024-01-16 18:27:58 +00:00
then
push_notification=" && (grep -q 'backup finished' /tmp/backup.log && curl -s '$PUSH_URL_SUCCESS' $push_fail_notification)"
2024-01-16 18:27:58 +00:00
fi
echo "$cron_schedule $push_start_notification backup --machine-logs create 2>&1 | tee /tmp/backup.log $push_notification" | crontab -
crontab -l
2021-11-11 00:10:17 +00:00
crond -f -d8 -L /dev/stdout