Search code examples
postgresqlbackupdatabase-backupskvmbackup-strategies

Backing up the DB vs. backing up the VM


We're serving a Django/Postgres site running on a VM hypervisor. We're now trying to figure out our back up strategy and have two probable options:

  1. Back up the DB directly using pg_dump
  2. Back up the VM directly by copying the VM image

I'm with the latter as I think, I could simply back up everything that has to do with the site. I'm not sure whether I have to shut down the VM for this though.

What is a better and more recommended way of backing up a DB? Are there any reasons for not using the VM backup?

Thanks


Solution

  • PostgreSQL recommends using pg_dump for backups, as a file system (or VM) backup requires the database to be shut down (and has other drawbacks):

    http://www.postgresql.org/docs/8.1/static/backup-file.html

    Edit: Also, a pg_dump backup will be significantly smaller than a filesystem dump of the same database.