{"id":18431575,"url":"https://github.com/jkaninda/pg-bkup","last_synced_at":"2026-02-14T07:04:12.102Z","repository":{"id":213653511,"uuid":"734607535","full_name":"jkaninda/pg-bkup","owner":"jkaninda","description":"Docker container image to Backup, Restore and Migrate PostgreSQL database to Local, AWS S3, FTP, SFTP, SSH remote Server, or Azure Blob Storage.","archived":false,"fork":false,"pushed_at":"2026-02-09T22:06:54.000Z","size":684,"stargazers_count":50,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-10T01:59:28.025Z","etag":null,"topics":["aws","backup-tool","backup-utility","databa-backup","docker-postgres-backup","docker-postgresql","docker-postgresql-backup","kubernetes-postgres-backup","kubernetes-postgresql-backup","minio","pg-backup-azure","postgres-backup","postgres-backup-azure","postgres-backup-s3","postgresql","s3"],"latest_commit_sha":null,"homepage":"https://jkaninda.github.io/pg-bkup/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jkaninda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"ko_fi":"jkaninda"}},"created_at":"2023-12-22T06:00:22.000Z","updated_at":"2026-02-09T22:06:28.000Z","dependencies_parsed_at":"2024-01-22T21:32:43.513Z","dependency_job_id":"10d3fe70-9826-43af-887d-b51e63812abb","html_url":"https://github.com/jkaninda/pg-bkup","commit_stats":null,"previous_names":["jkaninda/pg-bkup"],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/jkaninda/pg-bkup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkaninda%2Fpg-bkup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkaninda%2Fpg-bkup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkaninda%2Fpg-bkup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkaninda%2Fpg-bkup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkaninda","download_url":"https://codeload.github.com/jkaninda/pg-bkup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkaninda%2Fpg-bkup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29438988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T05:24:35.651Z","status":"ssl_error","status_checked_at":"2026-02-14T05:24:34.830Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","backup-tool","backup-utility","databa-backup","docker-postgres-backup","docker-postgresql","docker-postgresql-backup","kubernetes-postgres-backup","kubernetes-postgresql-backup","minio","pg-backup-azure","postgres-backup","postgres-backup-azure","postgres-backup-s3","postgresql","s3"],"created_at":"2024-11-06T05:25:30.667Z","updated_at":"2026-02-14T07:04:12.097Z","avatar_url":"https://github.com/jkaninda.png","language":"Go","funding_links":["https://ko-fi.com/jkaninda"],"categories":[],"sub_categories":[],"readme":"# PG-BKUP\n\n**PG-BKUP** is a Docker container image designed to **backup, restore, and migrate PostgreSQL databases**.\nIt supports a variety of storage options and ensures data security through GPG encryption.\n\nPG-BKUP is designed for seamless deployment on **Docker** and **Kubernetes**, simplifying PostgreSQL backup, restoration, and migration across environments.\nIt is a lightweight, multi-architecture solution compatible with **Docker**, **Docker Swarm**, **Kubernetes**, and other container orchestration platforms.\n\n[![Tests](https://github.com/jkaninda/pg-bkup/actions/workflows/tests.yml/badge.svg)](https://github.com/jkaninda/pg-bkup/actions/workflows/tests.yml)\n[![Build](https://github.com/jkaninda/pg-bkup/actions/workflows/release.yml/badge.svg)](https://github.com/jkaninda/pg-bkup/actions/workflows/release.yml)\n[![Go Report](https://goreportcard.com/badge/github.com/jkaninda/mysql-bkup)](https://goreportcard.com/report/github.com/jkaninda/pg-bkup)\n![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/jkaninda/pg-bkup?style=flat-square)\n![Docker Pulls](https://img.shields.io/docker/pulls/jkaninda/pg-bkup?style=flat-square)\n\u003ca href=\"https://ko-fi.com/jkaninda\"\u003e\u003cimg src=\"https://uploads-ssl.webflow.com/5c14e387dab576fe667689cf/5cbed8a4ae2b88347c06c923_BuyMeACoffee_blue.png\" height=\"20\" alt=\"buy ma a coffee\"\u003e\u003c/a\u003e\n\n## Features\n\n- **Flexible Storage Backends:**\n    - Local filesystem\n    - Amazon S3 \u0026 S3-compatible storage (e.g., MinIO, Wasabi)\n    - FTP\n    - SSH-compatible storage\n    - Azure Blob storage\n\n- **Data Security:**\n    - Backups can be encrypted using **GPG** to ensure confidentiality.\n\n- **Deployment Flexibility:**\n    - Available as the [jkaninda/pg-bkup](https://hub.docker.com/r/jkaninda/pg-bkup) Docker image.\n    - Deployable on **Docker**, **Docker Swarm**, and **Kubernetes**.\n    - Supports recurring backups of PostgreSQL databases when deployed:\n        - On Docker for automated backup schedules.\n        - As a **Job** or **CronJob** on Kubernetes.\n\n- **Notifications:**\n    - Get real-time updates on backup success or failure via:\n        - **Telegram**\n        - **Email**\n\n## 💡Use Cases\n\n- **Scheduled Backups**: Automate recurring backups using Docker or Kubernetes.\n- **Disaster Recovery:** Quickly restore backups to a clean PostgreSQL instance.\n- **Database Migration**: Seamlessly move data across environments using the built-in `migrate` feature.\n- **Secure Archiving:** Keep backups encrypted and safely stored in the cloud or remote servers.\n\n## 🚀 Why Use PG-BKUP?\n\n**PG-BKUP** isn't just another PostgreSQL backup tool, it's a robust, production-ready solution purpose-built for modern DevOps workflows.\n\nHere’s why developers, sysadmins, and DevOps choose **PG-BKUP**:\n\n### ✅ All-in-One Backup, Restore \u0026 Migration\n\nWhether you're backing up a single database, restoring critical data, or migrating across environments, PG-BKUP handles it all with a **single, unified CLI** no scripting gymnastics required.\n\n\n### 🔄 Works Everywhere You Deploy\n\nDesigned to be cloud-native:\n\n* **Runs seamlessly on Docker, Docker Swarm, and Kubernetes**\n* Supports **CronJobs** for automated scheduled backups\n* Compatible with GitOps and CI/CD workflows\n\n### ☁️ Flexible Storage Integrations\n\nStore your backups **anywhere**:\n\n* Local disks\n* Amazon S3, MinIO, Wasabi, Azure Blob, FTP, SSH\n\n### 🔒 Enterprise-Grade Security\n\n* **GPG Encryption**: Protect sensitive data with optional encryption before storing backups locally or in the cloud.\n* **Secure Storage** Options: Supports S3, Azure Blob, SFTP, and SSH with encrypted transfers, keeping backups safe from unauthorized access.\n\n### 📬 Instant Notifications\n\nStay in the loop with real-time notifications via **Telegram** and **Email**. Know immediately when a backup succeeds—or fails.\n\n### 🏃‍♂️ Lightweight and Fast\n\nWritten in **Go**, PG-BKUP is fast, multi-arch compatible (`amd64`, `arm64`, `arm/v7`), and optimized for minimal memory and CPU usage. Ideal for both cloud and edge deployments.\n\n### 🧪 Tested. Verified. Trusted.\n\nActively maintained with **automated testing**, **Docker image size optimizations**, and verified support across major container platforms.\n\n---\n\n## Supported PostgreSQL Versions\n\nPG-BKUP supports PostgreSQL versions **9.5** and above, ensuring compatibility with most modern PostgreSQL deployments.\n\n## ✅ Verified Platforms\nPG-BKUP has been tested and runs successfully on:\n\n- Docker\n- Docker Swarm\n- Kubernetes\n- OpenShift\n\n## Documentation is found at \u003chttps://jkaninda.github.io/pg-bkup\u003e\n\n\n## Useful links\n\n- [Docker Hub](https://hub.docker.com/r/jkaninda/pg-bkup)\n- [Github](https://github.com/jkaninda/pg-bkup)\n\n### MySQL solution :\n\n- [MySQL](https://github.com/jkaninda/mysql-bkup)\n\n\n## Quickstart\n\n### Simple Backup Using Docker CLI\n\nTo perform a one-time backup, bind your local volume to `/backup` in the container and run the `backup` command:\n\n```shell\ndocker run --rm --network your_network_name \\\n  -v $PWD/backup:/backup/ \\\n  -e \"DB_HOST=dbhost\" \\\n  -e \"DB_PORT=5432\" \\\n  -e \"DB_USERNAME=username\" \\\n  -e \"DB_PASSWORD=password\" \\\n  jkaninda/pg-bkup backup -d database_name\n```\n\nAlternatively, use an environment file (`--env-file`) for configuration:\n\n```shell\ndocker run --rm --network your_network_name \\\n  --env-file your-env-file \\\n  -v $PWD/backup:/backup/ \\\n  jkaninda/pg-bkup backup -d database_name\n```\n\u003e Note: Use `data-only` flag to back up only the data without schema.\n\n\n#### Backup Schema Only\n\nTo back up only the schema of a specific database, use the `--schema-only` flag:\n\n```shell\ndocker run --rm --network your_network_name \\\n  -v $PWD/backup:/backup/ \\\n  -e \"DB_HOST=dbhost\" \\\n  -e \"DB_PORT=5432\" \\\n  -e \"DB_USERNAME=username\" \\\n  -e \"DB_PASSWORD=password\" \\\n  jkaninda/pg-bkup backup -d database_name --schema-only\n```\n\n#### Backup specific tables\n\nTo back up specific tables within a database, use the `--tables` or `-t` flag followed by a comma-separated list of table names:\n\n```shell\ndocker run --rm --network your_network_name \\\n  -v $PWD/backup:/backup/ \\\n  -e \"DB_HOST=dbhost\" \\\n  -e \"DB_PORT=5432\" \\\n  -e \"DB_USERNAME=username\" \\\n  -e \"DB_PASSWORD=password\" \\\n  jkaninda/pg-bkup backup -d database_name --tables table1,table2\n```\n\n\n### Backup All Databases\n\nTo back up all databases on the server, use the `--all-databases` or `-a` flag. By default, this creates individual backup files for each database.\n\n```shell\ndocker run --rm --network your_network_name \\\n  -v $PWD/backup:/backup/ \\\n  -e \"DB_HOST=dbhost\" \\\n  -e \"DB_PORT=5432\" \\\n  -e \"DB_USERNAME=username\" \\\n  -e \"DB_PASSWORD=password\" \\\n  jkaninda/pg-bkup backup --all-databases --disable-compression\n```\n\n\u003e **Note:** Use the `--all-in-one` or `-A` flag to combine backups into a single file.\n\n### Migrate database\n\nThe `migrate` command allows you to transfer a PostgreSQL database from a source to a target database in a single step, combining backup and restore operations.\n\n\n```bash\ndocker run --rm --network your_network_name \\\n  --env-file your-env \\\n  jkaninda/pg-bkup migrate\n```\n\n\u003e  **Note:** Use the `--all-databases` (`-a`) flag to migrate all databases, PG-BKUP supports database creation if it does not exist on the target database.\n\n\nFor database migration, refer to the [documentation](https://jkaninda.github.io/pg-bkup/how-tos/migrate.html).\n\n\n---\n\n### Simple Restore Using Docker CLI\n\nTo restore a database, bind your local volume to `/backup` and run the `restore` command:\n\n```shell\ndocker run --rm --network your_network_name \\\n  -v $PWD/backup:/backup/ \\\n  -e \"DB_HOST=dbhost\" \\\n  -e \"DB_PORT=5432\" \\\n  -e \"DB_USERNAME=username\" \\\n  -e \"DB_PASSWORD=password\" \\\n  jkaninda/pg-bkup restore -d database_name -f backup_file.sql.gz\n```\n\n---\n\n### Backup with Docker Compose\n\nBelow is an example of a `docker-compose.yml` file for running a one-time backup:\n\n```yaml\nservices:\n  pg-bkup:\n    # In production, pin your image tag to a specific release version instead of `latest`.\n    # See available releases: https://github.com/jkaninda/pg-bkup/releases\n    image: jkaninda/pg-bkup\n    container_name: pg-bkup\n    command: backup\n    volumes:\n      - ./backup:/backup\n    environment:\n      - DB_PORT=5432\n      - DB_HOST=postgres\n      - DB_NAME=foo\n      - DB_USERNAME=bar\n      - DB_PASSWORD=password\n      - TZ=Europe/Paris\n    networks:\n      - web\n\nnetworks:\n  web:\n```\n\n---\n\n### Recurring Backups with Docker\n\nYou can schedule recurring backups using the `--cron-expression` or `-e` flag:\n\n```shell\ndocker run --rm --network network_name \\\n  -v $PWD/backup:/backup/ \\\n  -e \"DB_HOST=hostname\" \\\n  -e \"DB_USERNAME=user\" \\\n  -e \"DB_PASSWORD=password\" \\\n  jkaninda/pg-bkup backup -d dbName --cron-expression \"@every 15m\"\n```\n\nFor predefined schedules, refer to the [documentation](https://jkaninda.github.io/pg-bkup/reference/#predefined-schedules).\n\n---\n\n## Running Multiple Backups in a Single Container\n\n**PG-BKUP** supports backing up multiple PostgreSQL databases in a single run using a configuration file. You can pass the file using the `--config` or `-c` flag, or by setting the `BACKUP_CONFIG_FILE` environment variable.\n\nThis is ideal for setups where multiple services or applications each require independent database backups.\n\n---\n\n### Example Configuration File\n\nBelow is a sample `config.yaml` file that defines multiple databases along with their respective connection and backup settings:\n\n```yaml\n# Optional: Global cron expression for scheduled backups.\n# Examples: \"@daily\", \"@every 5m\", \"0 3 * * *\"\ncronExpression: \"\"\n\ndatabases:\n  - host: lldap-db             # Optional: Overrides DB_HOST or uses DB_HOST_LLDAP.\n    port: 5432                 # Optional: Defaults to 5432. Overrides DB_PORT or uses DB_PORT_LLDAP.\n    name: lldap                # Required: Database name\n    user: lldap                # Optional: Can override via DB_USERNAME or uses DB_USERNAME_LLDAP.\n    password: password         # Optional: Can override via DB_PASSWORD or uses DB_PASSWORD_LLDAP.\n    path: /s3-path/lldap       # Required: Destination path (S3, FTP, SSH, etc.)\n\n  - host: keycloak-db\n    port: 5432\n    name: keycloak\n    user: keycloak\n    password: password\n    path: /s3-path/keycloak\n\n  - host: gitea-db\n    port: 5432\n    name: gitea\n    user: gitea\n    password: \"\"               # Can be empty or sourced from DB_PASSWORD_GITEA\n    path: /s3-path/gitea\n```\n\n\u003e 🔹 **Tip:** You can override any field using environment variables. For example, `DB_PASSWORD_KEYCLOAK` takes precedence over the `password` field for the `keycloak` entry.\n\n---\n\n## Docker Compose Setup\n\nTo run backups using this configuration in Docker Compose:\n\n1. Mount the configuration file into the container.\n2. Set the `BACKUP_CONFIG_FILE` environment variable or use the `-c` flag in the command.\n\n### Sample `docker-compose.yaml`\n\n```yaml\nservices:\n  pg-bkup:\n    image: jkaninda/pg-bkup\n    container_name: pg-bkup\n    command: backup -c /backup/config.yaml\n    volumes:\n      - ./backup:/backup                # Backup target directory\n      - ./config.yaml:/backup/config.yaml  # Mount configuration file\n    environment:\n      - DB_PASSWORD_GITEA=password\n      - BACKUP_CRON_EXPRESSION=@daily   # Optional: Overrides config file cronExpression\n    networks:\n      - web\n\nnetworks:\n  web:\n```\n\n\u003e ⚠️ Ensure the `pg-bkup` container shares a network with the target databases to allow proper connectivity.\n\n---\n## Deploy on Kubernetes\n\nFor Kubernetes, you can deploy `pg-bkup` as a Job or CronJob. Below are examples for both.\n\n### Kubernetes Backup Job\n\nThis example defines a one-time backup job:\n\n```yaml\napiVersion: batch/v1\nkind: Job\nmetadata:\n  name: backup-job\nspec:\n  ttlSecondsAfterFinished: 100\n  template:\n    spec:\n      containers:\n        - name: pg-bkup\n          # Pin the image tag to a specific release version in production.\n          # See available releases: https://github.com/jkaninda/pg-bkup/releases\n          image: jkaninda/pg-bkup\n          command: [\"backup\", \"-d\", \"db_name\"]\n          resources:\n            limits:\n              memory: \"128Mi\"\n              cpu: \"500m\"\n          env:\n            - name: DB_HOST\n              value: \"postgres\"\n            - name: DB_USERNAME\n              value: \"postgres\"\n            - name: DB_PASSWORD\n              value: \"password\"\n          volumeMounts:\n            - mountPath: /backup\n              name: backup\n      volumes:\n        - name: backup\n          hostPath:\n            path: /home/toto/backup # Directory location on the host\n            type: Directory # Optional field\n      restartPolicy: Never\n```\n\n### Kubernetes CronJob for Scheduled Backups\n\nFor scheduled backups, use a `CronJob`:\n\n```yaml\napiVersion: batch/v1\nkind: CronJob\nmetadata:\n  name: pg-bkup-cronjob\nspec:\n  schedule: \"0 2 * * *\" # Runs daily at 2 AM\n  jobTemplate:\n    spec:\n      template:\n        spec:\n          containers:\n            - name: pg-bkup\n              image: jkaninda/pg-bkup\n              command: [\"backup\", \"-d\", \"db_name\"]\n              env:\n                - name: DB_HOST\n                  value: \"postgres\"\n                - name: DB_USERNAME\n                  value: \"postgres\"\n                - name: DB_PASSWORD\n                  value: \"password\"\n              volumeMounts:\n                - mountPath: /backup\n                  name: backup\n          volumes:\n            - name: backup\n              hostPath:\n                path: /home/toto/backup\n                type: Directory\n          restartPolicy: OnFailure\n```\n---\n## Give a Star! ⭐\n\nIf this project helped you, do not skip on giving it a star on [GitHub](https://github.com/jkaninda/goma-gateway).Thanks!\n\n\n## Available image registries\n\nThis Docker image is published to both Docker Hub and the GitHub container registry.\nDepending on your preferences and needs, you can reference both `jkaninda/pg-bkup` as well as `ghcr.io/jkaninda/pg-bkup`:\n\n```\ndocker pull jkaninda/pg-bkup\ndocker pull ghcr.io/jkaninda/pg-bkup\n```\n\nDocumentation references Docker Hub, but all examples will work using ghcr.io just as well.\n\n## References\n\nWe created this image as a simpler and more lightweight alternative to existing solutions. Here’s why:\n\n- **Lightweight:** Written in Go, the image is optimized for performance and minimal resource usage.\n- **Multi-Architecture Support:** Supports `arm64` and `arm/v7` architectures.\n- **Docker Swarm Support:** Fully compatible with Docker in Swarm mode.\n- **Kubernetes Support:** Designed to work seamlessly with Kubernetes.\n\n\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Authors\n\n**Jonas Kaninda**\n- \u003chttps://github.com/jkaninda\u003e\n\n## Copyright\n\nCopyright (c) [2024] [Jonas Kaninda]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkaninda%2Fpg-bkup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkaninda%2Fpg-bkup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkaninda%2Fpg-bkup/lists"}