Open Source image based on Alpine Linux.
docker run -it --rm --name postgresql-backup-s3-crypt \
-e POSTGRESQL_HOST=172.17.0.1 \
-e POSTGRESQL_USER=root \
-e POSTGRESQL_PASSWORD=SuP3R_5tr0ng-P@S5w0rD \
-e POSTGRESQL_DATABASES='my_database_1 my_database_2 my_database_3' \
-e AWS_ACCESS_KEY_ID=MY_AWS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=my_super_secret_aws_access_key \
-e AWS_DEFAULT_REGION=eu-west-3 \
-e AWS_BUCKET_NAME=my-bucket-name \
-e ENCRYPTION_PASSPHRASE=My-5uP3R_Str0NG-_p@55PhrAse \
-e MAX_BACKUPS=7 \
-e CRON_TIME='0 5 * * *' \
cl00e9ment/postgresql-backup-s3-crypt
| Variable | Required | Description |
|---|---|---|
| POSTGRESQL_HOST | yes | The hostname or IP address of the PostgreSQL server. |
| POSTGRESQL_PORT | no | The port of the PostgreSQL server. If not set, it will be 5432. |
| POSTGRESQL_USER | yes | The PostgreSQL user that make the backup. |
| POSTGRESQL_PASSWORD | yes | The password of the PostgreSQL user that make the backup. |
| POSTGRESQL_DATABASES | yes | A space separated list of PostgreSQL databases to backup. |
| AWS_ACCESS_KEY_ID | yes | The ID of the AWS access key used to upload backups to S3. |
| AWS_SECRET_ACCESS_KEY | yes | The AWS access key used to upload backups to S3. |
| AWS_DEFAULT_REGION | yes | The AWS region where the bucket lives. |
| AWS_BUCKET_NAME | yes | The name of the AWS bucket where to upload the backups. |
| ENCRYPTION_PASSPHRASE | yes | The passphrase used to encrypt the backups before sending them to S3. |
| MAX_BACKUPS | no | The max number of backups of a specific database to keep on S3. If set, old backups will be deleted. If not set, no backup will be deleted. |
| CRON_TIME | yes | A cron schedule expression to indicate when the backups must be made (in UTC time). |
!!! WARNING !!!
Keep a copy of the ENCRYPTION_PASSPHRASE outside of your server, because if a problem occurs on your server, you will not be able to recover your backups.
!!! WARNING !!!
Do not enable bucket versioning, because PostgreSQL Backup S3 Crypt handle versioning by itself.
Commands that can be run when the container is running.
Replace [DATABASES]... by a list of space separated databases to backup or leave it empty to backup all databases given in POSTGRES_DATABASES environment variable.
docker exec postgresql-backup-s3-crypt backup [DATABASES]...
docker exec postgresql-backup-s3-crypt list
docker exec postgresql-backup-s3-crypt list my_database_3
You can use the fetch command to print on stdin the content of a backup file. The script will download, decrypt and decompress the file for you.
docker exec postgresql-backup-s3-crypt fetch my_database_3-20210227025458-8c34f5b1ef4c5feacb672f75975f26bc655bb842.sql.xz.gpg
Content type
Image
Digest
Size
101.9 MB
Last updated
almost 5 years ago
docker pull cl00e9ment/postgresql-backup-s3-crypt