Allow overriding cron schedule, fix vars

This commit is contained in:
3wc 2021-11-10 21:17:12 +02:00
parent c9de239e93
commit 721c393d2d
4 changed files with 21 additions and 5 deletions

View File

@ -4,10 +4,16 @@ SECRET_RESTIC_PASSWORD_VERSION=v1
COMPOSE_FILE=compose.yml
SERVER_NAME=example.com
RESTIC_HOST=minio.example.com
CRON_SCHEDULE='*/5 * * * *'
# SSH storage
#SECRET_SSH_KEY_VERSION=v1
#COMPOSE_FILE="$COMPOSE_FILE:compose.ssh.yml"
# S3 storage
#SECRET_AWS_SECRET_ACCESS_KEY_VERSION=v1
#AWS_ACCESS_KEY_ID=something-secret
#COMPOSE_FILE="$COMPOSE_FILE:compose.s3.yml"

View File

@ -7,9 +7,7 @@ RUN apk add --upgrade --no-cache \
restic
COPY backup.sh /usr/bin/backup.sh
RUN chmod +x /usr/bin/backup.sh
COPY setup-cron.sh /usr/bin/setup-cron.sh
RUN chmod +x /usr/bin/backup.sh /usr/bin/setup-cron.sh
RUN echo "* * * * * /usr/bin/backup.sh" | crontab -
RUN crontab -l
ENTRYPOINT ["crond", "-f", "-L", "/dev/stdout"]
ENTRYPOINT [ "/usr/bin/setup-cron.sh" ]

View File

@ -8,6 +8,7 @@ services:
- "/var/run/docker.sock:/var/run/docker.sock"
- "backups:/backups"
environment:
- CRON_SCHEDULE
- RESTIC_REPO
- RESTIC_PASSWORD_FILE=/run/secrets/restic_password
- BACKUP_DEST=/backups

11
setup-cron.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
set -o pipefail
cron_schedule="${CRON_SCHEDULE:?CRON_SCHEDULE not set}"
echo "$cron_schedule /usr/bin/backup.sh" | crontab -
crontab -l
crond -f -L /dev/stdout