Postgres inplace PITR (point in time recovery) or rollback
There is no such facility in PostgreSQL but maybe a template database could help.
Create the template database as a copy of the production system. Then, whenever you need a test database, clone it with
CREATE DATABASE testdb TEMPLATE templatedb;