1
0
mirror of https://github.com/garraflavatra/docker-volume-s3-backup.git synced 2025-06-28 05:35:10 +00:00

filter backups by database name

This commit is contained in:
Elliott Shugerman
2019-12-01 20:02:12 -07:00
parent de8f9b0df6
commit 0f1ad642dd
2 changed files with 6 additions and 6 deletions

View File

@ -8,7 +8,7 @@ fork goals:
- [x] dedicated repository - [x] dedicated repository
- [x] automated builds - [x] automated builds
- [x] support multiple PostgreSQL versions - [x] support multiple PostgreSQL versions
- [x] merge backup and restore images? - [x] merge backup and restore images
- [x] support encrypted (password-protected) backups - [x] support encrypted (password-protected) backups
- [x] option to restore from specific backup by timestamp - [x] option to restore from specific backup by timestamp
@ -18,6 +18,7 @@ other changes:
- recreate all database objects on restore - recreate all database objects on restore
- some env vars renamed - some env vars renamed
- only scheduled backups supported, not ad-hoc - only scheduled backups supported, not ad-hoc
- filter backups on S3 by database name
# Usage # Usage
@ -32,7 +33,7 @@ postgres:
pg_backup_s3: pg_backup_s3:
image: eeshugerman/postgres-backup-s3:11 image: eeshugerman/postgres-backup-s3:11
environment: environment:
SCHEDULE: '@daily' SCHEDULE: '@weekly
PASSPHRASE: passphrase PASSPHRASE: passphrase
S3_REGION: region S3_REGION: region
S3_ACCESS_KEY_ID: key S3_ACCESS_KEY_ID: key
@ -48,14 +49,13 @@ pg_backup_s3:
- If `PASSPHRASE` is provided, the backup will be encrypted using GPG. - If `PASSPHRASE` is provided, the backup will be encrypted using GPG.
## Restore ## Restore
> **WARNING**: DATA LOSS! All database objects will be dropped and re-created. > **WARNING:** DATA LOSS! All database objects will be dropped and re-created.
### ... from latest backup ### ... from latest backup
```sh ```sh
docker exec <container name> sh restore.sh docker exec <container name> sh restore.sh
``` ```
- If your bucket has more than a 1000 files, the latest may not be restored -- only one S3 `ls` command is used > **NOTE:** If your bucket has more than a 1000 files, the latest may not be restored -- only one S3 `ls` command is used
- Your S3 prefix should only contain backups which you wish to restore -- 'latest' is determined based on unix sort with no filtering
### ... from specific backup ### ... from specific backup
```sh ```sh

View File

@ -70,7 +70,7 @@ if [ $# -eq 1 ]; then
else else
echo "Finding latest backup..." echo "Finding latest backup..."
key_suffix=$( key_suffix=$(
aws $aws_args s3 ls "${s3_uri_base}/" \ aws $aws_args s3 ls "${s3_uri_base}/${POSTGRES_DATABASE}" \
| sort \ | sort \
| tail -n 1 \ | tail -n 1 \
| awk '{ print $4 }' | awk '{ print $4 }'