Sign inSign up

michechel10/postgresql-backup-s3

By michechel10

•Updated almost 2 years ago

Backup postgres

Image
0

256

michechel10/postgresql-backup-s3 repository overview

⁠postgres-backup-s3

Backup PostgresSQL to S3 (supports periodic backups)

⁠Basic Usage

$ docker run -e S3_ACCESS_KEY_ID="sua-chave" -e S3_SECRET_ACCESS_KEY="sua-chave-secreta" -e POSTGRES_DATABASE="nome-do-banco" -e POSTGRES_HOST="host-do-postgres" -e POSTGRES_USER="seu-usuario" -e POSTGRES_PASSWORD="sua-senha" -e S3_BUCKET="seu-bucket" -e TZ="America/Sao_Paulo" meu-backup-postgres-s3

⁠ENV exemple the use


TZ=America/Sao_Paulo
POSTGRES_DATABASE=all
POSTGRES_HOST=db_postgres
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD='YOU PASSWORD'
S3_ACCESS_KEY_ID='YOU ID KEY'
S3_SECRET_ACCESS_KEY='YOU ACCESS KEY'
S3_BUCKET=backup
S3_PREFIX=postgres
S3_REGION=us-west-1
S3_ENDPOINT=https://s3.domain.com
S3_S3V4=yes
SCHEDULE=20 * * *
DELETE_OLDER_THAN=30 days ago

⁠Environment variables

VariableDefaultRequiredDescription
POSTGRES_DATABASEYDatabase you want to backup or 'all' to backup everything. In 'All' with V2 the banks are listed separately with the appropriate names and dates.
POSTGRES_HOSTYThe PostgreSQL host
POSTGRES_PORT5432The PostgreSQL port
POSTGRES_USERYThe PostgreSQL user
POSTGRES_PASSWORDYThe PostgreSQL password
POSTGRES_EXTRA_OPTSExtra postgresql options
S3_ACCESS_KEY_IDYYour AWS access key
S3_SECRET_ACCESS_KEYYYour AWS secret key
S3_BUCKETYYour AWS S3 bucket path
S3_PREFIXbackupPath prefix in your bucket
S3_REGIONus-west-1The AWS S3 bucket region
S3_ENDPOINTThe AWS Endpoint URL, for S3 Compliant APIs such as minio⁠
S3_S3V4noSet to yes to enable AWS Signature Version 4, required for minio⁠ servers
SCHEDULEBackup schedule time, see explainatons below
ENCRYPTION_PASSWORDPassword to encrypt the backup. Can be decrypted using openssl aes-256-cbc -d -in backup.sql.gz.enc -out backup.sql.gz
DELETE_OLDER_THANDelete old backups, see explanation and warning below
TZAmerica/Sao_Paulo
⁠Automatic Periodic Backups

You can additionally set the SCHEDULE environment variable like -e SCHEDULE="@daily" to run the backup automatically.

More information about the scheduling can be found here⁠.

⁠Delete Old Backups

You can additionally set the DELETE_OLDER_THAN environment variable like -e DELETE_OLDER_THAN="30 days ago" to delete old backups.

WARNING: this will delete all files in the S3_PREFIX path, not just those created by this script.

⁠Encryption

You can additionally set the ENCRYPTION_PASSWORD environment variable like -e ENCRYPTION_PASSWORD="superstrongpassword" to encrypt the backup. It can be decrypted using openssl aes-256-cbc -d -in backup.sql.gz.enc -out backup.sql.gz.

Tag summary

Content type

Image

Digest

sha256:585120f0e…

Size

47.7 MB

Last updated

almost 2 years ago

docker pull michechel10/postgresql-backup-s3:v2