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
|
2021-08-21 19:05:49 +02:00
|
|
|
mkdir -p /etc/backup
|
|
|
|
cat <<EOF > /etc/backup.env
|
2021-04-02 13:59:47 +02:00
|
|
|
BACKUP_SOURCES="${BACKUP_SOURCES:-/backup}"
|
|
|
|
BACKUP_CRON_EXPRESSION="${BACKUP_CRON_EXPRESSION:-@daily}"
|
2021-08-19 09:25:53 +02:00
|
|
|
BACKUP_FILENAME="${BACKUP_FILENAME:-backup-%Y-%m-%dT%H-%M-%S.tar.gz}"
|
|
|
|
BACKUP_ARCHIVE="${BACKUP_ARCHIVE:-/archive}"
|
2021-04-02 13:59:47 +02:00
|
|
|
|
|
|
|
BACKUP_RETENTION_DAYS="${BACKUP_RETENTION_DAYS:-}"
|
2021-08-22 21:06:51 +02:00
|
|
|
BACKUP_PRUNING_LEEWAY="${BACKUP_PRUNING_LEEWAY:-1m}"
|
2021-08-19 13:55:15 +02:00
|
|
|
BACKUP_PRUNING_PREFIX="${BACKUP_PRUNING_PREFIX:-}"
|
2021-08-19 09:25:53 +02:00
|
|
|
BACKUP_STOP_CONTAINER_LABEL="${BACKUP_STOP_CONTAINER_LABEL:-true}"
|
2021-04-02 13:59:47 +02:00
|
|
|
|
|
|
|
AWS_S3_BUCKET_NAME="${AWS_S3_BUCKET_NAME:-}"
|
|
|
|
AWS_ENDPOINT="${AWS_ENDPOINT:-s3.amazonaws.com}"
|
2021-07-09 09:21:42 +02:00
|
|
|
AWS_ENDPOINT_PROTO="${AWS_ENDPOINT_PROTO:-https}"
|
2021-08-22 19:26:34 +02:00
|
|
|
AWS_ENDPOINT_INSECURE="${AWS_ENDPOINT_INSECURE:-}"
|
2021-04-02 13:59:47 +02:00
|
|
|
|
|
|
|
GPG_PASSPHRASE="${GPG_PASSPHRASE:-}"
|
|
|
|
EOF
|
2021-08-21 19:05:49 +02:00
|
|
|
chmod a+x /etc/backup.env
|
|
|
|
source /etc/backup.env
|
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
|