Docker image for backing up Postgres databases using PG Dump and Backblaze
This docker image contains b2 command line tool as well as postgres client with pg_dump tool.
To backup your Postgres Database you can run the following command:
docker run \
-e PG_HOST=<posgres_host> \
-e PG_USER=<postgres_user> \
-e PG_PASSWORD=<postgres_password> \
-e PG_DUMP_DBS="space separated list of databases to backup" \
-e B2_APPLICATION_KEY_ID=<b2_application_key_id> \
-e B2_APPLICATION_KEY=<b2_application_key> \
-e B2_BUCKET=<b2_bucket_path> \
b2-pg-backup
The following envrionment variables are available:
| Name | Description | Required |
|---|---|---|
| PG_HOST | The hostname or IP Address of the Postgres instance to bucket. Must be acessible by the container. | Yes |
| PG_USER | The Postgres user to authenticate | Yes |
| PG_PASSWORD | The Postgres user password | Yes |
| PG_PORT | Postgres Database Port. Defaults to 5432 if not set | No |
| PG_DUMP_DBS | A space separated string with the list of database names to backup. | Yes |
| PG_DUMP_ARGS | Optional List of extra args to pass to the "pg_dump" command. Ex: ("--inserts --no-owner" | No |
| B2_BUCKET | The backbalze Bucket name. Can contain a subfolder. Ex: my-bucket/subfolder | Yes |
| B2_APPLICATION_KEY_ID | Backblaze Application Key ID credential | Yes |
| B2_APPLICATION_KEY | Backblaze Application Key credential | Yes |
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)It is recommended to install direnv and lefthook to a better development process.
make setup-env
This will install the Git Hooks and create an .env file from the .env.example template. You will need to add your backblaze keys there.
You can start a test Postgres container as well an application container using: make dev.
All the core logic is placed on backup.sh script at the root of this repository. This file is mounted as a volume on the docker container, so you can easily change it and see your changes.
If this project was useful to you in some form, I would be glad to have your support. It will help to keep the project alive and to have more time to work on Open Source.
The sinplest form of support is to give a ⭐️ to this repo.
You can also contribute with GitHub Sponsors.
Or if you prefer a one time donation to the project, you can simple:
👤 Bruno Paz
Copyright © 2021 Bruno Paz.
This project is MIT licensed.
Content type
Image
Digest
Size
25.5 MB
Last updated
over 4 years ago
docker pull brpaz/b2-pg-backup:1.0.0