How can I instruct Postgres to complete all "in-progress" transactions, but to delay starting new ones (without kicking clients off) until I have taken a ZFS or LVM snapshot (which takes less than a second).
e.g.
- pause Postgres, waiting for "in-progress" transactions to complete
- sync to disk
- take ZFS/LVM snapshot
- resume Postgres
This answer on dba.stackexchange seems to be what you are after.
Comments do not seem to automatically link in the side bar (inside the network), so I need to write some more stuff to prevent auto-conversion to a comment... yeah.
The post mentioned in @user121391 answer is correct, but in short:
postgres
process on the snapshot, the database will start in recovery mode (as when the previous process stopped abnormally).pg_start_backup
will make recovery process a little faster (since a checkpoint is made, and there will be less pending writes in WAL)