5

I know PostgresQL pg_dump guarantees consistency even if DB is modified while dump is going on, but I want to know if the final dump contains any data modified/inserted after the dump started.

To elaborate:

  1. Time t: I start pg_dump
  2. Time t+1: There are updates/inserts to the database
  3. Time t+x: pg_dump completes.

I don't want any of the modifications done in the 'x' period to be present in the dump file.

Is this possible?

George Netu
  • 2,758
  • 4
  • 28
  • 49
Finslicer
  • 868
  • 8
  • 8
  • If in doubt [read the manual](http://www.postgresql.org/docs/current/static/app-pgdump.html): "*It makes consistent backups even if the database is being used concurrently*" –  Jul 13 '15 at 12:17

1 Answers1

9

This was answered in another SO question: Doing pg_dump while still many active transaction.

The short answer is yes: pg_dump opens a transaction and no changes made to the database will be visible to it during the dump, so pg_dump snapshots are atomic and are a consistent snapshot (iow, no foreign key or other constraints will be violated in the snapshot).

HTH

Community
  • 1
  • 1
Kyle Burton
  • 26,788
  • 9
  • 50
  • 60