{"id":31108674,"url":"https://github.com/chappio/docker-postgres-backup-transip-stack","last_synced_at":"2025-09-17T06:44:44.411Z","repository":{"id":313862307,"uuid":"1053184392","full_name":"ChappIO/docker-postgres-backup-transip-stack","owner":"ChappIO","description":"A simple docker container to backup a postgres server to TransIP Stack","archived":false,"fork":false,"pushed_at":"2025-09-09T05:45:34.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-09T08:30:50.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChappIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-09-09T05:30:01.000Z","updated_at":"2025-09-09T05:44:45.000Z","dependencies_parsed_at":"2025-09-09T08:30:52.304Z","dependency_job_id":"d5b8893c-ac55-48f4-ad3b-4b5062b81b4b","html_url":"https://github.com/ChappIO/docker-postgres-backup-transip-stack","commit_stats":null,"previous_names":["chappio/docker-postgres-backup-transip-stack"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ChappIO/docker-postgres-backup-transip-stack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChappIO%2Fdocker-postgres-backup-transip-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChappIO%2Fdocker-postgres-backup-transip-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChappIO%2Fdocker-postgres-backup-transip-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChappIO%2Fdocker-postgres-backup-transip-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChappIO","download_url":"https://codeload.github.com/ChappIO/docker-postgres-backup-transip-stack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChappIO%2Fdocker-postgres-backup-transip-stack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275548909,"owners_count":25484678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-09-17T06:44:40.698Z","updated_at":"2025-09-17T06:44:44.398Z","avatar_url":"https://github.com/ChappIO.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postgres-transip-backup\n\nContainer that dumps a PostgreSQL database and uploads the compressed dump to **TransIP STACK** (WebDAV) using `rclone`.\nIt also prunes old backups using a configurable retention period.\n\n* **Image:** `ghcr.io/chappio/postgres-transip-backup`\n* **Base:** `alpine:3.22`\n* **Tools inside:** `pg_dump` (PostgreSQL 17 client), `rclone`, `openssh-client`\n* **Run mode:** one-shot (run it on a schedule with cron/Kubernetes/GitHub Actions/etc.)\n\n---\n\n## How it works\n\n1. Configures an in-memory `rclone` remote named `stack` from the provided STACK env vars.\n2. Dumps **one** database using `pg_dump -Fp` (plain SQL) and gzips it.\n3. Uploads to `stack:${TRANSIP_STACK_FOLDER}/`.\n4. Deletes remote files older than `BACKUP_RETENTION_TIME`.\n5. Cleans up the temp dir and exits.\n\n**Filename pattern:**\n`${PGDATABASE}-${YYYY-MM-DD}.sql.gz` (e.g., `appdb-2025-09-09.sql.gz`)\n\n---\n\n## Quick start\n\n```bash\ndocker run --rm \\\n  -e PGHOST=db.example.internal \\\n  -e PGPORT=5432 \\\n  -e PGUSER=app \\\n  -e PGPASSWORD=secret \\\n  -e PGDATABASE=appdb \\\n  -e TRANSIP_STACK_HOSTNAME=stack.example.com \\\n  -e TRANSIP_STACK_USERNAME=my-stack-user \\\n  -e TRANSIP_STACK_PASSWORD=my-stack-password \\\n  -e TRANSIP_STACK_FOLDER=/postgres_backup \\\n  -e BACKUP_RETENTION_TIME=30d \\\n  ghcr.io/chappio/postgres-transip-backup:latest\n```\n\nThis creates (or reuses) `/postgres_backup` on STACK, uploads today’s dump, prunes files older than the configured\nretention, and exits.\n\n---\n\n## Environment variables\n\n### PostgreSQL (required unless defaults apply)\n\nStandard libpq variables used by `pg_dump`:\n\n* `PGHOST` – Hostname or IP of your PostgreSQL server\n* `PGPORT` – Port (default: `5432`)\n* `PGUSER` – Database user with dump privileges\n* `PGPASSWORD` – Password for `PGUSER`\n* `PGDATABASE` – Name of the database to dump\n\nOptional passthrough: `PGSSLMODE`, `PGSSLROOTCERT`, `PGSSLCERT`, `PGSSLKEY`, etc.\n\n\u003e `pg_dump` version is **17** in the image. Keep client/server majors close when possible.\n\n### TransIP STACK (required)\n\n* `TRANSIP_STACK_HOSTNAME` – e.g. `example.stackstorage.com`\n* `TRANSIP_STACK_USERNAME` – STACK username\n* `TRANSIP_STACK_PASSWORD` – STACK password\n* `TRANSIP_STACK_FOLDER` – Folder path on STACK (default: `/postgres_backup`)\n\n### Retention\n\n* `BACKUP_RETENTION_TIME` – How long to **keep** backups remotely (default: `30d`).\n  Examples: `7d`, `14d`, `8w`, `90d`. Internally used as:\n\n  ```sh\n  rclone delete --min-age \"$BACKUP_RETENTION_TIME\" stack:${TRANSIP_STACK_FOLDER}/\n  ```\n\n---\n\n## Scheduling examples\n\n### Host cron (nightly at 02:15)\n\n```\n15 2 * * * docker run --rm \\\n  -e PGHOST=db \\\n  -e PGPORT=5432 \\\n  -e PGUSER=app \\\n  -e PGPASSWORD=secret \\\n  -e PGDATABASE=appdb \\\n  -e TRANSIP_STACK_HOSTNAME=stack.example.com \\\n  -e TRANSIP_STACK_USERNAME=my-stack-user \\\n  -e TRANSIP_STACK_PASSWORD=my-stack-password \\\n  -e TRANSIP_STACK_FOLDER=/postgres_backup \\\n  -e BACKUP_RETENTION_TIME=30d \\\n  ghcr.io/chappio/postgres-transip-backup:latest\n```\n\n### Docker Compose (trigger via external scheduler)\n\n```yaml\nservices:\n  pg-backup:\n    image: ghcr.io/chappio/postgres-transip-backup:latest\n    restart: \"no\"\n    environment:\n      PGHOST: db\n      PGPORT: \"5432\"\n      PGUSER: app\n      PGPASSWORD: ${PGPASSWORD}\n      PGDATABASE: appdb\n      TRANSIP_STACK_HOSTNAME: stack.example.com\n      TRANSIP_STACK_USERNAME: ${STACK_USER}\n      TRANSIP_STACK_PASSWORD: ${STACK_PASS}\n      TRANSIP_STACK_FOLDER: /postgres_backup\n      BACKUP_RETENTION_TIME: 30d\n```\n\n### Kubernetes CronJob\n\n```yaml\napiVersion: batch/v1\nkind: CronJob\nmetadata:\n  name: postgres-transip-backup\nspec:\n  schedule: \"15 2 * * *\" # 02:15 every day\n  jobTemplate:\n    spec:\n      template:\n        spec:\n          restartPolicy: Never\n          containers:\n            - name: backup\n              image: ghcr.io/chappio/postgres-transip-backup:latest\n              env:\n                - name: PGHOST\n                  value: \"postgres.default.svc.cluster.local\"\n                - name: PGPORT\n                  value: \"5432\"\n                - name: PGUSER\n                  valueFrom: { secretKeyRef: { name: db-secrets, key: user } }\n                - name: PGPASSWORD\n                  valueFrom: { secretKeyRef: { name: db-secrets, key: password } }\n                - name: PGDATABASE\n                  value: \"appdb\"\n                - name: TRANSIP_STACK_HOSTNAME\n                  value: \"stack.example.com\"\n                - name: TRANSIP_STACK_USERNAME\n                  valueFrom: { secretKeyRef: { name: stack-secrets, key: user } }\n                - name: TRANSIP_STACK_PASSWORD\n                  valueFrom: { secretKeyRef: { name: stack-secrets, key: password } }\n                - name: TRANSIP_STACK_FOLDER\n                  value: \"/postgres_backup\"\n                - name: BACKUP_RETENTION_TIME\n                  value: \"30d\"\n```\n\n---\n\n## Restoring a backup\n\nDumps are **plain SQL** compressed with gzip.\n\n```bash\n# 1) Decompress\ngunzip appdb-2025-09-09.sql.gz\n\n# 2) Restore into an existing (empty) DB\npsql -h PGHOST -p 5432 -U app -d appdb -f appdb-2025-09-09.sql\n\n# (optional) Create the database first\ncreatedb -h PGHOST -p 5432 -U app appdb\n```\n\n\u003e `-Fp` does **not** include cluster-wide objects (roles, tablespaces). Use `pg_dumpall -g` separately if you need\n\u003e globals.\n\n---\n\n## Notes \u0026 tips\n\n* **Single database per run.** Run the container multiple times to back up multiple DBs.\n* **Compression:** gzip; no parallel compression.\n* **Encryption at rest:** Not performed by the container. Consider an `rclone crypt` remote or server-side encryption.\n* **Networking:** Container must reach both your PostgreSQL host and the STACK WebDAV endpoint.\n* **Version skew:** Prefer matching `pg_dump` major to your server for best results.\n\n---\n\n## Troubleshooting\n\n**STACK auth fails**\n\n```bash\n# Start a debug shell and list remotes/dirs\ndocker run --rm -it \\\n  -e TRANSIP_STACK_HOSTNAME=... \\\n  -e TRANSIP_STACK_USERNAME=... \\\n  -e TRANSIP_STACK_PASSWORD=... \\\n  -e TRANSIP_STACK_FOLDER=/postgres_backup \\\n  --entrypoint sh \\\n  ghcr.io/chappio/postgres-transip-backup:latest\n\n# inside the container\nrclone lsd stack:/         # should list root\nrclone lsd stack:/postgres_backup\n```\n\n**`pg_dump` errors**\n\n* Check connectivity (`PGHOST`, port, firewall).\n* Verify credentials and privileges.\n* Add SSL envs (e.g., `PGSSLMODE=require`) if your server enforces TLS.\n\n**No pruning occurs**\n\n* Ensure `BACKUP_RETENTION_TIME` is set (e.g., `30d`).\n* Files newer than the retention period won’t be deleted.\n\n---\n\n## Build \u0026 publish (maintainers)\n\n```bash\n# build\ndocker build -t ghcr.io/chappio/postgres-transip-backup:latest .\n\n# login (GitHub Container Registry)\necho \"${GHCR_TOKEN}\" | docker login ghcr.io -u chappio --password-stdin\n\n# push\ndocker push ghcr.io/chappio/postgres-transip-backup:latest\n```\n\n---\n\n## License\n\nCopyright 2025 Thomas Biesaart\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the “Software”), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchappio%2Fdocker-postgres-backup-transip-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchappio%2Fdocker-postgres-backup-transip-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchappio%2Fdocker-postgres-backup-transip-stack/lists"}