How to get back the PostgreSQL database to a specific point in time? I was running a batch script in a PostgreSQL database which inserted values in different tables between 10:40 and 11:00. Later I came to know that the script was executed mistakenly. How can I get back my database to a state before 10:40 without stopping the server? I don't want the values which were inserted by batch during 10:40 to 11:00.

WAL has been configured.

I was struggling with this for the last three days. I have been trying with creating recovery.conf file with:

restore_command='path to my archivefile/%f %p'
recovery_target_time = '2014-10-15 10:40:00'
recovery_target_inclusive = true


Still I am not able to get my database backup to previous state.
If you know which rows were accidentally updated, you just don't know what the previous value of those rows were, then what you can do is:


Restore to a new non-production server from your base backup.
Recover that server to the point just before the error.
Write a query to select the values for the rows you know got mistakenly updated.
Turn that into a series of updates which can be run against the original production server.
Spin up yet another server which has been recovered up to current date to test those updates against to make sure they do the correct thing
Apply to production.


Of course if people or software have been relying on the bad values between when the error was made and now, then reversing the error will not reverse the decisions they made based on bad data.