sleep 10 minutes before pruning backups

if pruning happens immediatley after taking the backup a race condition
can occur where a backup that would theoretically be eligible won't be
pruned as the current backup run was very fast, putting the potential
candidate just at the very edge of the selected time window
This commit is contained in:
Frederik Ring 2021-04-08 08:17:55 +02:00
parent 204a0862c6
commit 2892369677
2 changed files with 2 additions and 0 deletions

View File

@ -72,6 +72,7 @@ echo "Will wait for next scheduled backup."
if [ ! -z "$BACKUP_RETENTION_DAYS" ]; then
info "Pruning old backups"
echo "Sleeping ${BACKUP_PRUNING_LEEWAY} before checking eligibility."
bucket=$AWS_S3_BUCKET_NAME
rule_applies_to=$(mc rm --fake --recursive -force --older-than "${BACKUP_RETENTION_DAYS}d" "backup-target/$bucket" | wc -l)

View File

@ -15,6 +15,7 @@ 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:-}"
BACKUP_PRUNING_LEEWAY="${BACKUP_PRUNING_LEEWAY:-10m}"
AWS_S3_BUCKET_NAME="${AWS_S3_BUCKET_NAME:-}"
AWS_ENDPOINT="${AWS_ENDPOINT:-s3.amazonaws.com}"