You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides Docker images to periodically back up a PostgreSQL database to AWS S3, and to restore from the backup as needed.
3
4
4
5
# Usage
6
+
5
7
## Backup
8
+
6
9
```yaml
7
10
services:
8
11
postgres:
9
-
image: postgres:16
12
+
image: postgres:17-alpine
10
13
environment:
11
14
POSTGRES_USER: user
12
15
POSTGRES_PASSWORD: password
13
16
14
17
backup:
15
-
image: eeshugerman/postgres-backup-s3:16
18
+
image: ghcr.io/solectrus/postgres-s3-backup:17
16
19
environment:
17
-
SCHEDULE: '@weekly'# optional
18
-
BACKUP_KEEP_DAYS: 7# optional
19
-
PASSPHRASE: passphrase # optional
20
+
SCHEDULE: '@weekly'# optional
21
+
BACKUP_KEEP_DAYS: 7# optional
22
+
PASSPHRASE: passphrase # optional
20
23
S3_REGION: region
21
24
S3_ACCESS_KEY_ID: key
22
25
S3_SECRET_ACCESS_KEY: secret
@@ -28,18 +31,20 @@ services:
28
31
POSTGRES_PASSWORD: password
29
32
```
30
33
31
-
- Images are tagged by the major PostgreSQL version supported: `12`, `13`, `14`, `15` or `16`.
34
+
- Images are tagged by the major PostgreSQL version supported: `13`, `14`, `15`, `16` or `17`.
32
35
- 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.
33
36
- If `PASSPHRASE` is provided, the backup will be encrypted using GPG.
34
37
- Run `docker exec <container name> sh backup.sh` to trigger a backup ad-hoc.
35
38
- If `BACKUP_KEEP_DAYS` is set, backups older than this many days will be deleted from S3.
36
39
- Set `S3_ENDPOINT` if you're using a non-AWS S3-compatible storage provider.
37
40
38
41
## Restore
42
+
39
43
> [!CAUTION]
40
44
> DATA LOSS! All database objects will be dropped and re-created.
41
45
42
46
### ... from latest backup
47
+
43
48
```sh
44
49
docker exec <container name> sh restore.sh
45
50
```
@@ -48,40 +53,31 @@ docker exec <container name> sh restore.sh
48
53
> If your bucket has more than a 1000 files, the latest may not be restored -- only one S3 `ls` command is used
49
54
50
55
### ... from specific backup
56
+
51
57
```sh
52
58
docker exec <container name> sh restore.sh <timestamp>
## Run a simple test environment with Docker Compose
72
+
62
73
```sh
63
74
cp template.env .env
64
75
# fill out your secrets/params in .env
65
76
docker compose up -d
66
77
```
67
78
68
79
# Acknowledgements
69
-
This 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).
70
-
71
-
## Fork goals
72
-
These changes would have been difficult or impossible merge into @schickling's repo or similarly-structured forks.
73
-
- dedicated repository
74
-
- automated builds
75
-
- support multiple PostgreSQL versions
76
-
- backup and restore with one image
77
-
78
-
## Other changes and features
79
-
- some environment variables renamed or removed
80
-
- uses `pg_dump`'s `custom` format (see [docs](https://www.postgresql.org/docs/10/app-pgdump.html))
81
-
- drop and re-create all database objects on restore
82
-
- backup blobs and all schemas by default
83
-
- no Python 2 dependencies
84
-
- filter backups on S3 by database name
85
-
- support encrypted (password-protected) backups
86
-
- support for restoring from a specific backup by timestamp
87
-
- support for auto-removal of old backups
80
+
81
+
This project is a fork of @eeshugerman's [postgres-backup-s3](https://github.com/eeshugerman/postgres-backup-s3) repository. Since the original project is no longer maintained, I decided to fork it and merge an important pull request ([#61](https://github.com/eeshugerman/postgres-backup-s3/pull/61)) to add support for PostgreSQL 17.
82
+
83
+
The original repository itself is a fork and restructuring 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).
0 commit comments