2021-04-02 13:59:47 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copyright 2021 - Offen Authors <hioffen@posteo.de>
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
|
|
# Portions of this file are taken from github.com/futurice/docker-volume-backup
|
|
|
|
# See NOTICE for information about authors and licensing.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Write cronjob env to file, fill in sensible defaults, and read them back in
|
|
|
|
cat <<EOF > env.sh
|
|
|
|
BACKUP_SOURCES="${BACKUP_SOURCES:-/backup}"
|
|
|
|
BACKUP_CRON_EXPRESSION="${BACKUP_CRON_EXPRESSION:-@daily}"
|
|
|
|
BACKUP_FILENAME=${BACKUP_FILENAME:-"backup-%Y-%m-%dT%H-%M-%S.tar.gz"}
|
|
|
|
|
|
|
|
BACKUP_RETENTION_DAYS="${BACKUP_RETENTION_DAYS:-}"
|
2021-04-08 08:17:55 +02:00
|
|
|
BACKUP_PRUNING_LEEWAY="${BACKUP_PRUNING_LEEWAY:-10m}"
|
2021-04-02 13:59:47 +02:00
|
|
|
|
|
|
|
AWS_S3_BUCKET_NAME="${AWS_S3_BUCKET_NAME:-}"
|
|
|
|
AWS_ENDPOINT="${AWS_ENDPOINT:-s3.amazonaws.com}"
|
|
|
|
|
|
|
|
GPG_PASSPHRASE="${GPG_PASSPHRASE:-}"
|
2021-05-24 20:34:30 +02:00
|
|
|
|
2021-06-26 21:16:22 +02:00
|
|
|
BACKUP_STOP_CONTAINER_LABEL="${BACKUP_STOP_CONTAINER_LABEL:-true}"
|
|
|
|
|
2021-05-25 07:35:21 +02:00
|
|
|
MC_GLOBAL_OPTIONS="${MC_GLOBAL_OPTIONS:-}"
|
2021-04-02 13:59:47 +02:00
|
|
|
EOF
|
|
|
|
chmod a+x env.sh
|
|
|
|
source env.sh
|
|
|
|
|
2021-05-25 07:35:21 +02:00
|
|
|
mc $MC_GLOBAL_OPTIONS alias set backup-target "https://$AWS_ENDPOINT" "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY"
|
2021-04-02 13:59:47 +02:00
|
|
|
|
|
|
|
# Add our cron entry, and direct stdout & stderr to Docker commands stdout
|
2021-04-03 09:33:11 +02:00
|
|
|
echo "Installing cron.d entry with expression $BACKUP_CRON_EXPRESSION."
|
2021-04-02 13:59:47 +02:00
|
|
|
echo "$BACKUP_CRON_EXPRESSION backup 2>&1" | crontab -
|
|
|
|
|
|
|
|
# Let cron take the wheel
|
2021-04-03 09:33:11 +02:00
|
|
|
echo "Starting cron in foreground."
|
2021-04-02 13:59:47 +02:00
|
|
|
crond -f -l 8
|