2023-05-30 12:37:42 +00:00
|
|
|
#!/bin/sh
|
2021-11-10 19:17:12 +00:00
|
|
|
|
2023-09-07 23:48:09 +00:00
|
|
|
set -e -o pipefail
|
2023-05-30 12:37:42 +00:00
|
|
|
|
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
|
2021-11-10 19:17:12 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-03-08 14:42:00 +00:00
|
|
|
if [ -n "$PUSH_URL_FAIL" ]
|
2024-01-16 18:27:58 +00:00
|
|
|
then
|
2024-03-08 14:42:00 +00:00
|
|
|
push_fail_notification="|| curl -s '$PUSH_URL_FAIL'"
|
2024-01-16 18:27:58 +00:00
|
|
|
fi
|
|
|
|
|
2024-03-08 14:42:00 +00:00
|
|
|
if [ -n "$PUSH_URL_SUCCESS" ]
|
2024-01-16 18:27:58 +00:00
|
|
|
then
|
2024-03-08 14:42:00 +00:00
|
|
|
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
|
|
|
|
|
2024-03-08 14:42:00 +00:00
|
|
|
echo "$cron_schedule $push_start_notification backup --machine-logs create 2>&1 | tee /tmp/backup.log $push_notification" | crontab -
|
2021-11-11 10:05:04 +00:00
|
|
|
crontab -l
|
2021-11-10 19:17:12 +00:00
|
|
|
|
2021-11-11 00:10:17 +00:00
|
|
|
crond -f -d8 -L /dev/stdout
|