Skip to content

Commit 29e083e

Browse files
committed
Improve the example usage scenario
Update the documentation. Upgrade the DB server to Alpine 3.15 and PostgreSQL 11.15. Provide an updated test database.
1 parent a7b0c51 commit 29e083e

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

README.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ Service to backup and/or restore a PostgreSQL database using S3
88
4. Run a backup and check your bucket for that backup
99

1010
### Environment variables
11-
`MODE=[backup|restore]`
11+
`MODE` Valid values: `backup`, `restore`
1212

13-
`DB_HOST=` hostname of the database server
13+
`DB_HOST` hostname of the database server
1414

15-
`DB_NAME=` name of the database
15+
`DB_NAME` name of the database
1616

17-
`DB_OPTIONS=opt1 opt2 opt3 ...` optional arguments to supply to the backup or restore commands
17+
`DB_OPTIONS` optional arguments to supply to the backup or restore commands
1818

19-
`DB_ROOTPASSWORD=` password for the `DB_ROOTUSER`
19+
`DB_ROOTPASSWORD` password for the `DB_ROOTUSER`
2020

21-
`DB_ROOTUSER=` database administrative user, typically "postgres" for PostgreSQL databases
21+
`DB_ROOTUSER` database administrative user, typically "postgres" for PostgreSQL databases
2222

23-
`DB_USERPASSWORD=` password for the `DB_USER`
23+
`DB_USERPASSWORD` password for the `DB_USER`
2424

25-
`DB_USER=` user that accesses the database (PostgreSQL "role")
25+
`DB_USER` user that accesses the database (PostgreSQL "role")
2626

27-
`AWS_ACCESS_KEY=` used for S3 interactions
27+
`AWS_ACCESS_KEY` used for S3 interactions
2828

29-
`AWS_SECRET_KEY=` used for S3 interactions
29+
`AWS_SECRET_KEY` used for S3 interactions
3030

31-
`S3_BUCKET=` _e.g., s3://database-backups_ **NOTE: no trailing slash**
31+
`S3_BUCKET` e.g., _s3://database-backups_ **NOTE: no trailing slash**
3232

3333
>**It's recommended that your S3 bucket have versioning turned on.**
3434
@@ -38,9 +38,22 @@ This image is built automatically on Docker Hub as [silintl/postgresql-backup-re
3838
## Playing with it locally
3939
You'll need [Docker](https://www.docker.com/get-docker), [Docker Compose](https://docs.docker.com/compose/install/), and [Make](https://www.gnu.org/software/make/).
4040

41-
1. `cp local.env.dist local.env` and supply variables
42-
2. Ensure you have a `gz` dump in your S3 bucket to be used for testing. A test database is provided as part of this project in the `test` folder. You can copy it to S3 as follows:
41+
1. Copy `local.env.dist` to `local.env`.
42+
2. Edit `local.env` to supply values for the variables.
43+
3. Ensure you have a `gz` dump in your S3 bucket to be used for testing. A test database is provided as part of this project in the `test` folder. You can copy it to S3 as follows:
4344
* `aws s3 cp test/world.sql.gz ${S3_BUCKET}/world.sql.gz`
44-
3. `make`
45-
46-
A UI into the local database will then be running at [http://localhost:8080](http://localhost:8080)
45+
4. `make db` # creates the Postgres DB server
46+
5. `make restore` # restores the DB dump file
47+
6. `docker ps -a` # get the Container ID of the exited restore container
48+
7. `docker logs <containerID>` # review the restoration log messages
49+
8. `make backup` # create a new DB dump file
50+
9. `docker ps -a` # get the Container ID of the exited backup container
51+
10. `docker logs <containerID>` # review the backup log messages
52+
11. `make restore` # restore the DB dump file from the new backup
53+
12. `docker ps -a` # get the Container ID of the exited restore container
54+
13. `docker logs <containerID>` # review the restoration log messages
55+
14. `make clean` # remove containers and network
56+
15. `docker volume ls` # find the volume ID of the Postgres data container
57+
16. `docker volume rm <volumeID>` # remove the data volume
58+
17. `docker images` # list existing images
59+
18. `docker image rm <imageID ...>` # remove images no longer needed

docker-compose.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ services:
1010
# POSTGRES_USER - superuser (default is 'postgres')
1111
# POSTGRES_DB - name of default database (default is value of POSTGRES_USER)
1212
db:
13-
image: postgres:9.6-alpine
13+
image: postgres:11.15-alpine3.15
1414
volumes_from:
1515
- data
1616
ports:
1717
- "5432"
1818
environment:
1919
POSTGRES_PASSWORD: r00tp@ss!
2020

21-
# adminer:
22-
# image: adminer:4.6.3
23-
# ports:
24-
# - "8080:8080"
25-
2621
# DB_HOST - hostname of the database server
2722
# DB_ROOTUSER - administrative user for the database server
2823
# DB_ROOTPASSWORD - password for the DB_ROOTUSER
@@ -39,8 +34,8 @@ services:
3934
DB_HOST: db
4035
DB_ROOTUSER: postgres
4136
DB_ROOTPASSWORD: r00tp@ss!
42-
DB_USER: postgres
43-
DB_USERPASSWORD: r00tp@ss!
37+
DB_USER: dbuser
38+
DB_USERPASSWORD: dbuserpass
4439
DB_NAME: world
4540
MODE: restore
4641
CRON_SCHEDULE: "25 * * * *"
@@ -55,8 +50,8 @@ services:
5550
DB_HOST: db
5651
DB_ROOTUSER: postgres
5752
DB_ROOTPASSWORD: r00tp@ss!
58-
DB_USER: postgres
59-
DB_USERPASSWORD: r00tp@ss!
53+
DB_USER: dbuser
54+
DB_USERPASSWORD: dbuserpass
6055
DB_NAME: world
6156
MODE: backup
6257
CRON_SCHEDULE: "20 * * * *"

test/world.sql.gz

-32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)