Skip to content

A "http-wrapper" around pg_dump written in GoLang - Allowing to easily trigger (by invoking an HTTP endpoint) the creation and restoring of database dumps.

Notifications You must be signed in to change notification settings

rlindooren/pg_dumper

Repository files navigation

pg_dumper

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".

Usage example

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:

List all dumps

curl "localhost:9999/list"

The response should be empty initially (since no dump was made yet).

Dump the current database state

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]):

List again

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)

Restore an earlier made dump

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]):

About

A "http-wrapper" around pg_dump written in GoLang - Allowing to easily trigger (by invoking an HTTP endpoint) the creation and restoring of database dumps.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages