Sign inSign up

brpaz/b2-pg-backup

By brpaz

•Updated over 4 years ago

Image
0

121

brpaz/b2-pg-backup repository overview

⁠b2-pg-backup

Docker image for backing up Postgres databases using PG Dump⁠ and Backblaze⁠

Docker Pulls MicroBadger Layers MicroBadger Size GitHub Workflow Status

⁠Requirements

  • A Backblaze⁠ account.
  • A B2 Bucket to store your backup files - Create a new one here⁠.
  • An Application Key⁠ with write access to the previous created backup. This is required to authenticate in your B2 account to upload files.

⁠Usage

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:

NameDescriptionRequired
PG_HOSTThe hostname or IP Address of the Postgres instance to bucket.
Must be acessible by the container.
Yes
PG_USERThe Postgres user to authenticateYes
PG_PASSWORDThe Postgres user passwordYes
PG_PORTPostgres Database Port. Defaults to 5432 if not setNo
PG_DUMP_DBSA space separated string with the list of database names to backup.Yes
PG_DUMP_ARGSOptional List of extra args to pass to the "pg_dump" command. Ex: ("--inserts --no-owner"No
B2_BUCKETThe backbalze Bucket name. Can contain a subfolder.
Ex: my-bucket/subfolder
Yes
B2_APPLICATION_KEY_IDBackblaze Application Key ID credentialYes
B2_APPLICATION_KEYBackblaze Application Key credentialYes

⁠FAQ

⁠How to run backups on a schedule?
  • This tool doens´t assume how and when do you want to run your backups. If you want to run it on a schedule, you can run the regular tools for running scheduled tasks like Cron or Kubernetes Jobs.

⁠Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request
⁠Developing

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.

⁠💛 Support the project

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⁠.

GitHub Sponsors

Or if you prefer a one time donation to the project, you can simple:

Buy Me A Coffee

⁠Author

👤 Bruno Paz

⁠📝 License

Copyright © 2021 Bruno Paz⁠.

This project is MIT⁠ licensed.

Tag summary

Content type

Image

Digest

Size

25.5 MB

Last updated

over 4 years ago

docker pull brpaz/b2-pg-backup:1.0.0