← Back to context

Comment by dsr_

3 years ago

You have choices.

* shut down PG. Gain perfect consistency.

* use pg_dump. Perfect consistency at the cost of a longer transaction. Gain portability for major version upgrades.

* Don't shut down PG: here's what the manual says:

However, a backup created in this way saves the database files in a state as if the database server was not properly shut down; therefore, when you start the database server on the backed-up data, it will think the previous server instance crashed and will replay the WAL log. This is not a problem; just be aware of it (and be sure to include the WAL files in your backup). You can perform a CHECKPOINT before taking the snapshot to reduce recovery time.

* Midway: use SELECT pg_start_backup('label', false, false); and SELECT * FROM pg_stop_backup(false, true); to generate WAL files while you are running the backup, and add those to your backup.