th0th/postgres-s3-backup

By th0th

Updated 3 months ago

Docker image to backup a postgres database to S3

Image
0

252

postgres-s3-backup is a Postgres backup helper that:

  • Takes the dump of the Postgres database
  • Uploads it to AWS' object storage service S3
  • Reports to WebGazer Pulse (optional)

Usage

Environment variables
VariableRequiredDefault valueDescription
AWS_ACCESS_KEY_IDAccess key id for the AWS account
AWS_REGIONRegion for the AWS bucket
AWS_S3_ENDPOINTAWS S3 endpoint with bucket and path (e.g. "my-bucket/postgres-backup")
AWS_S3_STORAGE_CLASSSTANDARD_IAAWS S3 storage class (see https://aws.amazon.com/s3/storage-classes/ and https://rclone.org/s3/#s3-storage-class for options.
AWS_SECRET_ACCESS_KEYSecret access key for the AWS account
POSTGRES_DBPostgres server database
POSTGRES_HOSTpostgresPostgres server host
POSTGRES_PASSWORDPostgres server password
POSTGRES_PORT5432Postgres server port
POSTGRES_USERpostgresPostgres server user
POSTGRES_VERSION16Postgres server version (13, 14, 15 or 16)
WEBGAZER_PULSE_URLWebGazer Pulse URL
Running
$ docker run th0th/postgres-s3-backup \
    -e AWS_ACCESS_KEY_ID=<aws_access_key_id> \
    -e AWS_REGION=<aws_region> \
    -e AWS_S3_ENDPOINT=<aws_s3_endpoint> \
    -e AWS_S3_STORAGE_CLASS=<aws_s3_storage_class[STANDARD_IA]> \
    -e AWS_SECRET_ACCESS_KEY=<aws_secret_access_key> \
    -e POSTGRES_DB=<database> \
    -e POSTGRES_HOST=<postgres_hostname[postgres]> \
    -e POSTGRES_PASSWORD=<postgres_password> \
    -e POSTGRES_PORT=<postgres_port[5432]> \
    -e POSTGRES_USER=<postgres_user[postgres]> \
    -e POSTGRES_VERSION=<postgres_version[15]> \
    -e WEBGAZER_PULSE_URL=<webgazer_pulse_url>
Example
$ docker run th0th/postgres-s3-backup \
    -e AWS_ACCESS_KEY_ID=g9XqNnqKmUk6xqwkStkN \
    -e AWS_REGION=eu-west-1 \
    -e AWS_S3_ENDPOINT=my-bucket/postgres-backup \
    -e AWS_S3_STORAGE_CLASS=GLACIER \
    -e AWS_SECRET_ACCESS_KEY=GLBZ8mQf27UL57YHbkLhXWtfJWVwtUBbQup6mFzw \
    -e POSTGRES_DB=database \
    -e POSTGRES_HOST=postgres \
    -e POSTGRES_PASSWORD=postgres_password \
    -e POSTGRES_PORT=5432 \
    -e POSTGRES_USER=postgres_user \
    -e POSTGRES_VERSION=15 \
    -e WEBGAZER_PULSE_URL=https://pulse.webgazer.io/1-8f713c75d659

Shameless plug

I am an indie hacker, and I am running two services that might be useful for your business. Check them out :)

WebGazer

WebGazer

WebGazer is a monitoring service that checks your website, cron jobs, or scheduled tasks on a regular basis. It notifies you with instant alerts in case of a problem. That way, you have peace of mind about the status of your service without manually checking it.

PoeticMetric

PoeticMetric

PoeticMetric is a privacy-first, regulation-compliant, blazingly fast analytics tool.

No cookies or personal data collection. So you don't have to worry about cookie banners or GDPR, CCPA, and PECR compliance.

License

Copyright © 2022, Gokhan Sari. Released under the MIT License.

Docker Pull Command

docker pull th0th/postgres-s3-backup