We have a web application with PostgreSQL as our database and use celery background tasks for somewhat complex task. At the very beginning of this complex task we take a backup of the database using pg_dump.
I was wondering about the state of this sql dump if the users are still using the system. Could it cause any inconsistencies ?
Also, I would like to know if pg_dump is the best choice for taking backups in this case. Of course as the database grows the backup takes a lot of time which slows the overall process.
Thanks.
pg_dump
takes a consistent snapshot from the database so it will not cause any inconsistencies.pg_dump
creates a "snapshot". Usually that is not considered a backup. Using WAL archiving you can create "real" backups that also allow restoring the data to a specific point in time. See the manual for details: postgresql.org/docs/current/static/continuous-archiving.html