Skip to content

Commit

Permalink
Merge pull request #19 from ercpereda/add-aws-glacier-support
Browse files Browse the repository at this point in the history
Add aws glacier suport
  • Loading branch information
jareware authored Feb 24, 2021
2 parents 15c7694 + 80874ef commit a766e6f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Variable | Default | Notes
`BACKUP_WAIT_SECONDS` | `0` | The backup script will sleep this many seconds between re-starting stopped containers, and proceeding with archiving/uploading the backup. This can be useful if you don't want the load/network spike of a large upload immediately after the load/network spike of container startup.
`BACKUP_HOSTNAME` | `$(hostname)` | Name of the host (i.e. Docker container) in which the backup runs. Mostly useful if you want a specific hostname to be associated with backup metrics (see InfluxDB support).
`AWS_S3_BUCKET_NAME` | | When provided, the resulting backup file will be uploaded to this S3 bucket after the backup has ran.
`AWS_GLACIER_VAULT_NAME` | | When provided, the resulting backup file will be uploaded to this AWS Glacier vault after the backup has ran.
`AWS_ACCESS_KEY_ID` | | Required when using `AWS_S3_BUCKET_NAME`.
`AWS_SECRET_ACCESS_KEY` | | Required when using `AWS_S3_BUCKET_NAME`.
`AWS_DEFAULT_REGION` | | Optional when using `AWS_S3_BUCKET_NAME`. Allows you to override the AWS CLI default region. Usually not needed.
Expand Down
8 changes: 8 additions & 0 deletions src/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ if [ ! -z "$AWS_S3_BUCKET_NAME" ]; then
echo "Upload finished"
TIME_UPLOADED="$(date +%s.%N)"
fi
if [ ! -z "$AWS_GLACIER_VAULT_NAME" ]; then
info "Uploading backup to GLACIER"
echo "Will upload to vault \"$AWS_GLACIER_VAULT_NAME\""
TIME_UPLOAD="$(date +%s.%N)"
aws $AWS_EXTRA_ARGS glacier upload-archive --account-id - --vault-name "$AWS_GLACIER_VAULT_NAME" --body "$BACKUP_FILENAME"
echo "Upload finished"
TIME_UPLOADED="$(date +%s.%N)"
fi

if [ -d "$BACKUP_ARCHIVE" ]; then
info "Archiving backup"
Expand Down
1 change: 1 addition & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cat <<EOF > env.sh
BACKUP_SOURCES="${BACKUP_SOURCES:-/backup}"
BACKUP_CRON_EXPRESSION="${BACKUP_CRON_EXPRESSION:-@daily}"
AWS_S3_BUCKET_NAME="${AWS_S3_BUCKET_NAME:-}"
AWS_GLACIER_VAULT_NAME="${AWS_GLACIER_VAULT_NAME:-}"
AWS_EXTRA_ARGS="${AWS_EXTRA_ARGS:-}"
BACKUP_FILENAME=${BACKUP_FILENAME:-"backup-%Y-%m-%dT%H-%M-%S.tar.gz"}
BACKUP_ARCHIVE="${BACKUP_ARCHIVE:-/archive}"
Expand Down
25 changes: 25 additions & 0 deletions test/backing-up-to-glacier/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3"

services:

dashboard:
image: grafana/grafana
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana

backup:
build: ../..
environment:
BACKUP_CRON_EXPRESSION: "* * * * *"
BACKUP_FILENAME: glacier-test.tar.gz
AWS_GLACIER_VAULT_NAME: Backups
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
volumes:
- grafana-data:/backup/grafana-data:ro

volumes:
grafana-data:

0 comments on commit a766e6f

Please sign in to comment.