-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add aws secret handling * make it look go-ish * fix tests * whitespace * sleep a bit
- Loading branch information
Showing
6 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright 2020-2021 - Offen Authors <[email protected]> | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
version: '3.8' | ||
|
||
services: | ||
minio_setup: | ||
image: alpine:latest | ||
deploy: | ||
restart_policy: | ||
condition: none | ||
volumes: | ||
- backup_data:/data | ||
command: mkdir -p /data/backup | ||
|
||
minio: | ||
image: minio/minio:RELEASE.2021-12-20T22-07-16Z | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
environment: | ||
MINIO_ROOT_USER_FILE: /run/secrets/minio_root_user | ||
MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password | ||
command: minio server /data | ||
volumes: | ||
- backup_data:/data | ||
secrets: | ||
- minio_root_user | ||
- minio_root_password | ||
depends_on: | ||
- minio_setup | ||
|
||
backup: | ||
image: offen/docker-volume-backup:${TEST_VERSION:-canary} | ||
depends_on: | ||
- minio | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
environment: | ||
AWS_ACCESS_KEY_ID_FILE: /run/secrets/minio_root_user | ||
AWS_SECRET_ACCESS_KEY_FILE: /run/secrets/minio_root_password | ||
AWS_ENDPOINT: minio:9000 | ||
AWS_ENDPOINT_PROTO: http | ||
AWS_S3_BUCKET_NAME: backup | ||
BACKUP_FILENAME: test.tar.gz | ||
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ? | ||
BACKUP_RETENTION_DAYS: 7 | ||
BACKUP_PRUNING_LEEWAY: 5s | ||
volumes: | ||
- pg_data:/backup/pg_data:ro | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
secrets: | ||
- minio_root_user | ||
- minio_root_password | ||
|
||
offen: | ||
image: offen/offen:latest | ||
labels: | ||
- docker-volume-backup.stop-during-backup=true | ||
healthcheck: | ||
disable: true | ||
deploy: | ||
replicas: 2 | ||
restart_policy: | ||
condition: on-failure | ||
|
||
pg: | ||
image: postgres:14-alpine | ||
environment: | ||
POSTGRES_PASSWORD: example | ||
labels: | ||
- docker-volume-backup.stop-during-backup=true | ||
volumes: | ||
- pg_data:/var/lib/postgresql/data | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
|
||
volumes: | ||
backup_data: | ||
name: backup_data | ||
pg_data: | ||
|
||
secrets: | ||
minio_root_user: | ||
external: true | ||
minio_root_password: | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
cd $(dirname $0) | ||
. ../util.sh | ||
current_test=$(basename $(pwd)) | ||
|
||
docker swarm init | ||
|
||
printf "test" | docker secret create minio_root_user - | ||
printf "GMusLtUmILge2by+z890kQ" | docker secret create minio_root_password - | ||
|
||
docker stack deploy --compose-file=docker-compose.yml test_stack | ||
|
||
while [ -z $(docker ps -q -f name=backup) ]; do | ||
info "Backup container not ready yet. Retrying." | ||
sleep 1 | ||
done | ||
|
||
sleep 20 | ||
|
||
docker exec $(docker ps -q -f name=backup) backup | ||
|
||
docker run --rm -it \ | ||
-v backup_data:/data alpine \ | ||
ash -c 'tar -xf /data/backup/test.tar.gz && test -f /backup/pg_data/PG_VERSION' | ||
|
||
pass "Found relevant files in untared backup." | ||
|
||
sleep 5 | ||
expect_running_containers "5" | ||
|
||
docker stack rm test_stack | ||
|
||
docker secret rm minio_root_password | ||
docker secret rm minio_root_user | ||
|
||
docker swarm leave --force | ||
|
||
sleep 10 | ||
|
||
docker volume rm backup_data | ||
docker volume rm test_stack_pg_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters