Sign inSign up

gtuk/pg-dumper

By gtuk

Updated almost 5 years ago

Easily dump, compress and optionally encrypt your postgres database/cluster

Image
0

1.7K

gtuk/pg-dumper repository overview

pg-dumper

pg-dumper is a simple cli script to easily dump, compress, encrypt and optionally upload your postgres database/cluster.


Requirements

In order to run the script you need to have gnupg, gzip, the minio client (mc) and pg_dump/pg_dumpall installed (version should match the postgres server).

Make script executable
chmod +x pg-dumper.sh
Backup with encryption enabled
./pg-dumper.sh --host localhost --db app --password postgres --user postgres --port 5432 --backup-password supersecret --location ./
Backup with encryption disabled
./pg-dumper.sh --host localhost --db app --password postgres --user postgres --port 5432 location ./ --encryption false

Extract backup with encryption enabled
gpg -d backup_file.gpg | gzip -dc > backup_file.sql
Extract backup with encryption disabled
gzip -dc backup_file.gz > backup_file.sql
Parameters
ParameterDescriptionDefault
hostPostgres host(required)
userPostgres user(required)
passwordPostgres password(required)
dbPostgres db(required if cluster-wide is false)
portPostgres port5432
locationLocation for the backup$HOME
backup-passwordPassword for encryption(required if encryption is true)
encryptionEnable/disable encryptiontrue
cluster-wideIf true it will use pg_dumpall to dump the whole clusterfalse
uploadIf true it will upload the backup to a s3 compatible storagefalse
endpoints3 compatible endpoint(required if upload is true)
buckets3 bucket for uploading (needs to end with a slash)(required if upload is true)
access-keys3 compatible storage access-key(required if upload is true)
access-secrets3 compatible storage secret-key(required if upload is true)
api-versionapi-signature (minio client)S3v4
minio-clientcustom location of the minio client (e.g ./mc)mc
Build docker image
# Example to build for postgres 11.14
docker build --no-cache --build-arg PG_VERSION=11.14 -t pg-dumper:postgres-11.14 .
Prebuild docker images

https://hub.docker.com/r/gtuk/pg-dumper

docker run gtuk/pg-dumper:postgres-11.14 --host <HOST> --password <PASSWORD> --user <USER> --port <PORT> --backup-password <SUPER_SECRET_PASSWORD> --location ./ --cluster-wide true --upload true --endpoint <ENDPOINT> --access-key <ACCESS_KEY> --secret-key <SECRET_KEY> --bucket <BUCKET> --minio-client ./mc

Tag summary

Content type

Image

Digest

Size

160.7 MB

Last updated

almost 5 years ago

docker pull gtuk/pg-dumper:postgres-14.1