{"id":28047878,"url":"https://github.com/eeshugerman/postgres-backup-s3","last_synced_at":"2025-05-11T21:06:28.555Z","repository":{"id":40495283,"uuid":"224537891","full_name":"eeshugerman/postgres-backup-s3","owner":"eeshugerman","description":"A handy  Docker container to periodically backup PostgreSQL to S3","archived":false,"fork":false,"pushed_at":"2024-08-14T12:53:00.000Z","size":26290,"stargazers_count":600,"open_issues_count":21,"forks_count":216,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-10T04:35:37.314Z","etag":null,"topics":["docker","postgres","postgresql","s3"],"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/eeshugerman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-28T00:09:02.000Z","updated_at":"2025-05-04T09:31:34.000Z","dependencies_parsed_at":"2024-01-27T17:43:08.047Z","dependency_job_id":null,"html_url":"https://github.com/eeshugerman/postgres-backup-s3","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/eeshugerman%2Fpostgres-backup-s3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeshugerman%2Fpostgres-backup-s3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeshugerman%2Fpostgres-backup-s3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeshugerman%2Fpostgres-backup-s3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eeshugerman","download_url":"https://codeload.github.com/eeshugerman/postgres-backup-s3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253633122,"owners_count":21939389,"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":["docker","postgres","postgresql","s3"],"created_at":"2025-05-11T21:06:27.431Z","updated_at":"2025-05-11T21:06:28.537Z","avatar_url":"https://github.com/eeshugerman.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Introduction\nThis project provides Docker images to periodically back up a PostgreSQL database to AWS S3, and to restore from the backup as needed.\n\n# Usage\n## Backup\n```yaml\nservices:\n  postgres:\n    image: postgres:16\n    environment:\n      POSTGRES_USER: user\n      POSTGRES_PASSWORD: password\n\n  backup:\n    image: eeshugerman/postgres-backup-s3:16\n    environment:\n      SCHEDULE: '@weekly'     # optional\n      BACKUP_KEEP_DAYS: 7     # optional\n      PASSPHRASE: passphrase  # optional\n      S3_REGION: region\n      S3_ACCESS_KEY_ID: key\n      S3_SECRET_ACCESS_KEY: secret\n      S3_BUCKET: my-bucket\n      S3_PREFIX: backup\n      POSTGRES_HOST: postgres\n      POSTGRES_DATABASE: dbname\n      POSTGRES_USER: user\n      POSTGRES_PASSWORD: password\n```\n\n- Images are tagged by the major PostgreSQL version supported: `12`, `13`, `14`, `15` or `16`.\n- The `SCHEDULE` variable determines backup frequency. See go-cron schedules documentation [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). Omit to run the backup immediately and then exit.\n- If `PASSPHRASE` is provided, the backup will be encrypted using GPG.\n- Run `docker exec \u003ccontainer name\u003e sh backup.sh` to trigger a backup ad-hoc.\n- If `BACKUP_KEEP_DAYS` is set, backups older than this many days will be deleted from S3.\n- Set `S3_ENDPOINT` if you're using a non-AWS S3-compatible storage provider.\n\n## Restore\n\u003e [!CAUTION]\n\u003e DATA LOSS! All database objects will be dropped and re-created.\n\n### ... from latest backup\n```sh\ndocker exec \u003ccontainer name\u003e sh restore.sh\n```\n\n\u003e [!NOTE]\n\u003e If your bucket has more than a 1000 files, the latest may not be restored -- only one S3 `ls` command is used\n\n### ... from specific backup\n```sh\ndocker exec \u003ccontainer name\u003e sh restore.sh \u003ctimestamp\u003e\n```\n\n# Development\n## Build the image locally\n`ALPINE_VERSION` determines Postgres version compatibility. See [`build-and-push-images.yml`](.github/workflows/build-and-push-images.yml) for the latest mapping.\n```sh\nDOCKER_BUILDKIT=1 docker build --build-arg ALPINE_VERSION=3.14 .\n```\n## Run a simple test environment with Docker Compose\n```sh\ncp template.env .env\n# fill out your secrets/params in .env\ndocker compose up -d\n```\n\n# Acknowledgements\nThis project is a fork and re-structuring of @schickling's [postgres-backup-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-backup-s3) and [postgres-restore-s3](https://github.com/schickling/dockerfiles/tree/master/postgres-restore-s3).\n\n## Fork goals\nThese changes would have been difficult or impossible merge into @schickling's repo or similarly-structured forks.\n  - dedicated repository\n  - automated builds\n  - support multiple PostgreSQL versions\n  - backup and restore with one image\n\n## Other changes and features\n  - some environment variables renamed or removed\n  - uses `pg_dump`'s `custom` format (see [docs](https://www.postgresql.org/docs/10/app-pgdump.html))\n  - drop and re-create all database objects on restore\n  - backup blobs and all schemas by default\n  - no Python 2 dependencies\n  - filter backups on S3 by database name\n  - support encrypted (password-protected) backups\n  - support for restoring from a specific backup by timestamp\n  - support for auto-removal of old backups\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feeshugerman%2Fpostgres-backup-s3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feeshugerman%2Fpostgres-backup-s3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feeshugerman%2Fpostgres-backup-s3/lists"}