Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Keeping Your PostgreSQL Data Save

Keeping Your PostgreSQL Data Save

You love your data, and want to keep it save. Which is why you store it in PostgreSQL. But have you thought about what happens when disaster strikes?

Markus Wein

April 02, 2015
Tweet

More Decks by Markus Wein

Other Decks in Programming

Transcript

  1. “At 9:45 EST a user triggered an unscoped deletion of

    all historical period records […]” Dead Man's Snitch Outage Post Mortem
  2. Have someone else do it ✔ It’s someone else’s problem

    now ❌ less control ❌ can cost a lot ❌ less flexibility
  3. File-based backup methods ✔ Easy ✔ Widely available tools ❌

    Requires PostgreSQL server to be shut down
  4. pg_dump[all] ✔ Creates logical backup ✔ flexible ✔ no down

    time required ✔ minimal impact ❌ impractical for large databases
  5. hot standby ✔ Continuous ✔ use them to distribute read

    load ✔ good for fast failover ❌ only protects against hardware failure ❌ requires at least one more server
  6. # In postgresql.conf: wal_level = hot_standby # Set these to

    something > 0 max_wal_senders = 5 wal_keep_segments = 64
  7. $ pg_ctl start LOG: entering standby mode ... then some

    time later ... LOG: consistent recovery state reached LOG: database system is ready to accept read only connections
  8. PITR-based backups ✔ continuous backup ✔ high recoverability ✔ cluster-based

    ❌ complex ❌ increased I/O ❌ needs lots of storage ❌ architecture- dependAnt
  9. # Restore/untar latest base backup # Create a recovery.conf: restore_command

    = 'cp /path/to/archive/%f %p' # Start PostgreSQL
  10. 3rd party tools ✔ replicate between postgresql versions ✔ very

    flexible ✔ Paid support ❌ complicated ❌ setup & maintenance ❌ costs money