Amazon EC2 postgresql backups: Snapshot the data directory or pg_dump onto an EBS volume that is snapshotted consistently?

Viewed 2309

I have a postgresql database on amazon EC2 and need to determine the best way to keep this data backed up. I am considering two options:

(1) Mount an EBS volume to some directory like /pgsqldata and use this directory as the postgresql data directory (on Amazon Linux the default is /var/lib/pgsql/data/). Then this volume would get frequent snapshots.

or

(2) Keep the postgresql data directory in it's default location. Then use pg_dump to frequently dump backups to a location like /pgsqldumps and that volume will get a snapshot after each pg_dump.

A third option would be to simply snapshot the root device volume (I am using an EBS-backed instance) since it is both a webserver and database in my case. I like the idea of having a dedicated volume for data backups though.

Finally, if I am taking direct snapshots of the live postgresql data directory, do I need to worry about possible changes to the database during the snapshot process?

Thanks

1 Answers
Related