{"id":20453871,"url":"https://github.com/anyways-open/docker-postgres-dump","last_synced_at":"2026-04-13T02:04:04.621Z","repository":{"id":116245498,"uuid":"298666891","full_name":"anyways-open/docker-postgres-dump","owner":"anyways-open","description":"A docker image to create extracts for postgres containers.","archived":false,"fork":false,"pushed_at":"2022-12-17T09:21:25.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-15T23:18:12.359Z","etag":null,"topics":["backups","db","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/anyways-open.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-09-25T19:52:34.000Z","updated_at":"2023-01-14T15:15:40.000Z","dependencies_parsed_at":"2023-07-15T18:34:08.709Z","dependency_job_id":null,"html_url":"https://github.com/anyways-open/docker-postgres-dump","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyways-open%2Fdocker-postgres-dump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyways-open%2Fdocker-postgres-dump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyways-open%2Fdocker-postgres-dump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyways-open%2Fdocker-postgres-dump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anyways-open","download_url":"https://codeload.github.com/anyways-open/docker-postgres-dump/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242005826,"owners_count":20056434,"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","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":["backups","db","postgresql"],"created_at":"2024-11-15T11:14:12.448Z","updated_at":"2026-04-13T02:04:04.588Z","avatar_url":"https://github.com/anyways-open.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-postgres\n\nA docker image to create extracts from postgres.\n\n[![Production](https://github.com/anyways-open/docker-postgres/workflows/Production/badge.svg)](https://github.com/anyways-open/docker-postgres/actions?query=workflow%3AProduction)\n\nStatus: PRODUCTION :rocket:\n\n## Backups\n\nBackups are written to the volume `/var/lib/postgresql/dumps/` by executing \n\n  ```/usr/bin/pg_dump -U $PGDUMP_USER -p $PGDUMP_PORT -h $PGDUMP_HOST $PGDUMP_DB | gzip \u003e /var/lib/postgresql/dumps/db_dump_`date +%d-%m-%Y\"_\"%H_%M_%S`.sql.gz```\n\nThe should be **stored on the host by mapping the volume**.\n\nThe container by default:\n- keeps minutely backups for the last 2 hours.\n- keeps daily backups for the last 7 days.\n- keeps monthly backups for the last 365 days.\n- keep all yearlies.\n\n## Configuration\n\nThe container can be configure by using the following env vars:\n- PGDUMP_USER: the user, usually `postgres`\n- PGDUMP_PORT: the port, usually `5432`\n- PGDUMP_HOST: the hostname of the container hosting the db.\n- PGDUMP_DB: the name of the database to dump.\n- PGPASSWORD: the password or secret containing the password.\n\nConfigure **one** of the following to control when backups are taken:\n- PGDUMP_MINUTE: `true`, backups every minute.\n- PGDUMP_HOUR: `true`, backups every hour.\n- PGDUMP_DAY: `true`, backups every day.\n\nThe larger the database, the longer the interval. The next dump will already start even if the previous one hasn't yet finished.\n\nAn example configuration:\n\n```\n  identity-api-db:\n    image: postgres:11.1\n    hostname: identity-api-db\n    volumes:\n      - /var/services/core/identity/db:/var/lib/postgresql/data\n    environment:\n      POSTGRES_PASSWORD: _redacted_\n  identity-api-db-dump:\n    image: anywaysopen/postgres-dump:prod\n    volumes:\n      - /var/services/backups/identity-api-db-dump:/var/lib/postgresql/dumps\n    environment:\n      PGPASSWORD_FILE: /path/to/secret\n      PGDUMP_USER: postgres\n      PGDUMP_PORT: 5432\n      PGDUMP_HOST: identity-api-db\n      PGDUMP_DB: users\n      PGDUMP_HOUR: 'true'\n```\n\n## Restore\n\nRestoring a backup into an **empty** running docker container can be done as follows:\n\n   `cat db_dump_25-09-2020_21_47_16.sql | docker exec -i container-name psql -U postgres db-name`\n   \nFor example for restoring the edit-api we did the following:\n\n  `printf \"CREATE DATABASE \\\"edit-api\\\";\"  | docker exec -i 9cc0139c118a psql -U postgres`  \n  `gzip -d -c -k db_dump_11-11-2022_00_00_01.sql.gz | docker exec -i 9cc0139c118a psql -U postgres edit-api`\n   \n   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanyways-open%2Fdocker-postgres-dump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanyways-open%2Fdocker-postgres-dump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanyways-open%2Fdocker-postgres-dump/lists"}