Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chaosdorf/postgres-gpg-backup
chaosdorf backup for postgres instances in docker
https://github.com/chaosdorf/postgres-gpg-backup
postgres-backup
Last synced: 10 days ago
JSON representation
chaosdorf backup for postgres instances in docker
- Host: GitHub
- URL: https://github.com/chaosdorf/postgres-gpg-backup
- Owner: chaosdorf
- Created: 2018-09-01T22:31:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:56:50.000Z (about 1 year ago)
- Last Synced: 2024-11-06T02:43:31.547Z (about 2 months ago)
- Topics: postgres-backup
- Language: Shell
- Size: 2.93 KB
- Stars: 0
- Watchers: 18
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# backup postgres instances from within docker
This image includes postgres-client, openssh-client and GnuPG.
Inspired by [nomaster/postgres-backup-docker](https://github.com/nomaster/postgres-backup-docker).To encrypt backups, the script first retrieves a GPG key from default keyservers.
Every hour, a full postgres backup is created, compressed, encrypted and pushed to a remote SSH server.
The container can run beneath a postgres database within the same docker network.Required environment variables:
- `PGHOST`, `PGUSER`, `PGPASSWORD`: Postgres credentials
- `BACKUP_NAME`: To identify the backup on the remote hostOptional variables:
- `BACKUP_INTERVAL` (default: `1h`)
- `BACKUP_GPG_KEY_ID` (chaosdorf default)
- `BACKUP_SSH_DESTINATION` (chaosdorf default, should be `user@host`)
- `BACKUP_SSH_REMOTE_DIRECTORY` (chaosdorf default, directory must exist on remote host)# Example
Add service to `docker-compose.yml` and provide `id_rsa` to allow ssh to connect to the remote host:
```yml
version: '3.7'services:
db:
image: postgres:latest
networks:
- internal
[...]
backup:
image: chaosdorf/postgres-gpg-backup:latest
environment:
- PGHOST=db
- PGUSER=postgres
- PGPASSWORD=postgres
- BACKUP_NAME=db-backup
configs:
- source: backup_ssh_key
target: /root/.ssh/id_rsa
uid: '0'
gid: '0'
mode: 0600
networks:
- internalconfigs:
backup_ssh_key:
[...]
```