Re: is there a function in postgresql that can be used for retrieving deleted rows

From: Steve Atkins <steve(at)blighty(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: is there a function in postgresql that can be used for retrieving deleted rows
Date: 2011-10-22 17:28:29
Message-ID: D255D6D0-1FFB-4991-96E9-A7F2FD599342@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 21, 2011, at 10:23 PM, Charles Waweru wrote:

> I am looking for a tool in the PostgreSQL database that can help to audit fraudulent activities on a PostgreSQL database. Of particular interest is how to retrieve say from a PostgreSQL sales database all the deleted rows.
>
> Any suggestion please would be appreciated.

For forensics work after the fact the three database-specific places to look are the server logs, the WAL logs and the raw data files. The server logs are standard human readable logs which may or may not have anything useful in them.

Normal forensics rules - if you're not imaging the whole drive then take copies of everything first, then copies of those, and only work on the copies of copies.

https://github.com/snaga/xlogdump can show you what's in the WAL logs, but expect to spend some time working out what's going on.

The raw data files may have old rows in them, if they've not been overwritten yet. pg_filedump might help you there, depending on the version of postgresql you're running. (Most row updates are done by deleting an old row and creating a new one, so it doesn't make much traffic to wipe out the old rows if autovacuum is running).

Don't forget related logs and backups - logs from the front-end webserver, if any, and any backups.

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2011-10-22 17:39:58 Re: Are file system level differential/incremental backups possible?
Previous Message David Johnston 2011-10-22 17:12:44 Re: is there a function in postgresql that can be used for retrieving deleted rows