A small "HTTP-wrapper" around pg_dump
.
It can be used to trigger dumping and restoring of a Postgres database.
This can be useful to reset or prepare a database during automated tests that don't have control over, for example, the transactions (e.g. during Black-box testing).
An automated test can then simply control the database state by means of an HTTP "signal".
Using the example docker-compose.yaml. It also contains configuration hints.
In a terminal window: docker-compose up
Hint: use docker-compose down --volumes
to clean up any data that might exist for the example postgres database.
Then, in a different terminal window:
curl "localhost:9999/list"
The response should be empty initially (since no dump was made yet).
curl "localhost:9999/dump?name=some-state"
The response should look something like this:
SUCCESS
Succesfully executed pg_dump with arguments: [--clean --format=plain -f /dumps/some-state.dump.sql]):
curl "localhost:9999/list"
The response should now contain the dump that was just created, in the previous step. E.g.:
some-state (/dumps/some-state.dump.sql @ 2022-10-04 12:33:27.316599119 +0000 UTC)
curl "localhost:9999/restore?name=some-state"
The response should look something like this:
SUCCESS
Succesfully executed psql with arguments: [-f /dumps/some-state.dump.sql]):