diff --git a/README.md b/README.md index cb13a90..0a53220 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ AWS_SECRET_ACCESS_KEY="" AWS_S3_BUCKET_NAME="" # This is the FQDN of your storage server, e.g. `storage.example.com`. -# You can leave it blank when working against AWS S3. +# Do not set this when working against AWS S3. # AWS_ENDPOINT="" ########### BACKUP PRUNING diff --git a/src/backup.sh b/src/backup.sh index 33358be..cc679bb 100644 --- a/src/backup.sh +++ b/src/backup.sh @@ -12,7 +12,7 @@ function info { echo -e "\n[INFO] $1\n" } -info "Backup starting" +info "Preparing backup" DOCKER_SOCK="/var/run/docker.sock" if [ -S "$DOCKER_SOCK" ]; then @@ -25,12 +25,12 @@ if [ -S "$DOCKER_SOCK" ]; then CONTAINERS_TO_STOP_TOTAL="$(cat $TEMPFILE | wc -l)" CONTAINERS_TOTAL="$(docker ps --format "{{.ID}}" | wc -l)" rm "$TEMPFILE" - echo "$CONTAINERS_TOTAL containers running on host in total" - echo "$CONTAINERS_TO_STOP_TOTAL containers marked to be stopped during backup" + echo "$CONTAINERS_TOTAL containers running on host in total." + echo "$CONTAINERS_TO_STOP_TOTAL containers marked to be stopped during backup." else CONTAINERS_TO_STOP_TOTAL="0" CONTAINERS_TOTAL="0" - echo "Cannot access \"$DOCKER_SOCK\", won't look for containers to stop" + echo "Cannot access \"$DOCKER_SOCK\", won't look for containers to stop." fi if [ "$CONTAINERS_TO_STOP_TOTAL" != "0" ]; then @@ -57,9 +57,9 @@ fi if [ ! -z "$AWS_S3_BUCKET_NAME" ]; then info "Uploading backup to remote storage" - echo "Will upload to bucket \"$AWS_S3_BUCKET_NAME\"" + echo "Will upload to bucket \"$AWS_S3_BUCKET_NAME\"." mc cp "$BACKUP_FILENAME" "backup-target/$AWS_S3_BUCKET_NAME" - echo "Upload finished" + echo "Upload finished." fi if [ -f "$BACKUP_FILENAME" ]; then @@ -68,7 +68,7 @@ if [ -f "$BACKUP_FILENAME" ]; then fi info "Backup finished" -echo "Will wait for next scheduled backup" +echo "Will wait for next scheduled backup." if [ ! -z "$BACKUP_RETENTION_DAYS" ]; then info "Pruning old backups" @@ -76,18 +76,19 @@ if [ ! -z "$BACKUP_RETENTION_DAYS" ]; then rule_applies_to=$(mc rm --fake --recursive -force --older-than "${BACKUP_RETENTION_DAYS}d" "backup-target/$bucket" | wc -l) if [ "$rule_applies_to" == "0" ]; then - echo "No backups found that match the configured retention period. Doing nothing." + echo "No backups found older than the configured retention period of $BACKUP_RETENTION_DAYS days." + echo "Doing nothing." exit 0 fi - available=$(mc ls "backup-target/$bucket" | wc -l) + total=$(mc ls "backup-target/$bucket" | wc -l) - if [ "$rule_applies_to" == "$available" ]; then - echo "Using a retention of $BACKUP_RETENTION_DAYS days would prune all currently existing backups, will not continue." + if [ "$rule_applies_to" == "$total" ]; then + echo "Using a retention of ${BACKUP_RETENTION_DAYS} days would prune all currently existing backups, will not continue." echo "If this is what you want, please remove files manually instead of using this script." exit 1 fi mc rm --recursive -force --older-than "${BACKUP_RETENTION_DAYS}d" "backup-target/$bucket" - echo "Successfully pruned all backups older than ${BACKUP_RETENTION_DAYS} days" + echo "Successfully pruned ${rule_applies_to} backups older than ${BACKUP_RETENTION_DAYS} days." fi diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 34e12be..30c93de 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -27,9 +27,9 @@ source env.sh mc alias set backup-target "https://$AWS_ENDPOINT" "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" # Add our cron entry, and direct stdout & stderr to Docker commands stdout -echo "Installing cron.d entry with expression $BACKUP_CRON_EXPRESSION" +echo "Installing cron.d entry with expression $BACKUP_CRON_EXPRESSION." echo "$BACKUP_CRON_EXPRESSION backup 2>&1" | crontab - # Let cron take the wheel -echo "Starting cron in foreground" +echo "Starting cron in foreground." crond -f -l 8