Sign inSign up

nhamlh/postgres-s3-backup

By nhamlh

•Updated about 7 years ago

Backup postgres databases to S3 bucket

Image
0

2.4K

nhamlh/postgres-s3-backup repository overview

⁠Description

This image contains a simple bash script to dump all database of defined postgres server then upload them to S3 bucket. This image is built specific for RDS postgres instances to overcome some RDS restrictions:

  • We couldn't read role passwords
  • We couldn't use pg_dumpall to easily dump all databases of the server at once because we couldn't read rdsadmin database. There're a pull request to support --exclude-database for pg_dumpall but it hasn't done yet.

⁠How it works

The bash script will iterate each line in file PGPASSDFILE, get a list of databases then dump each of them using pg_dump. The script then compress the dump files, finally upload it to S3 bucket.

⁠Environments

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • S3_BUCKET

⁠.pgpass⁠

The user for each database must has the privileges to access all databases

grant usage on schema public to <user>;
grant select on all tables in schema public to <user>;

⁠Docker image

docker pull nhamlh/postgres-s3-backup

Tag summary

Content type

Image

Digest

Size

59.2 MB

Last updated

about 7 years ago

docker pull nhamlh/postgres-s3-backup