the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the...
Transcript of the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the...
![Page 1: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/1.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 1/50
PostgreSQL BackupsPostgreSQL Backupsthe Modern Waythe Modern Way
Nordic PGDay 2019 Copenhagen, Denmark
Magnus Hagander [email protected]
![Page 2: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/2.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 2/50
Magnus HaganderMagnus HaganderRedpill Linpro
Infrastructure servicesPrincipal database consultant
PostgreSQLCore Team memberCommitterPostgreSQL Europe
![Page 3: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/3.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 3/50
So, backups...So, backups...Do you make them?
![Page 4: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/4.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 4/50
BackupsBackupsAre not superseded by replicationOr cloudOr containers..
![Page 5: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/5.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 5/50
BackupsBackupsAre boringBut I'm glad you have them
![Page 6: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/6.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 6/50
BackupsBackupsWhen did you last restore?
![Page 7: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/7.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 7/50
PostgreSQL backupsPostgreSQL backupsOk, enough genericWhat about backups in PostgreSQL?
![Page 8: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/8.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 8/50
Seen this before?Seen this before?pg_dump options:pg_dump options:
-Fc = custom format -Z = compression -j = parallel -a = data only, -s = schema only -n = schema, -t = table ...
![Page 9: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/9.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 9/50
pg_dumppg_dumpDon't use for backups
Has other good usecasesToo slow to restoreToo much overheadNo PITRExceptions, of course
![Page 10: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/10.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 10/50
Physical backupsPhysical backupsBase backupsWith or without log archiveFast restoreFull cluster onlyPlatform specific
![Page 11: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/11.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 11/50
Base backupsBase backups #!/bin/bash set -e psql -U postgres -q "SELECT pg_start_backup('foo')" tar cfz /backup/$(date +%Y%m%d).tar.gz /var/lib/pgsql/data psql -U postgres -q "SELECT pg_stop_backup()"
![Page 12: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/12.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 12/50
Base backupsBase backupsSo many ways to get that wrong
Spot one?
![Page 13: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/13.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 13/50
Base backupsBase backupsThis used to be the only wayMany scripts around that does itMost of those are broken...
![Page 14: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/14.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 14/50
pg_basebackuppg_basebackupBase backup over replication protocolSafeError handling and recoveryFor most cases
(we'll cover other options later)
![Page 15: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/15.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 15/50
pg_basebackuppg_basebackup #!/bin/bash set -e pg_basebackup -D /backup/$(date +%Y%m%d) -Ft
![Page 16: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/16.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 16/50
Needs replicationNeeds replicationEnabled by default in 10!Older versions:
wal_level = hot_standby max_wal_senders = 10
local replication postgres peer
![Page 17: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/17.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 17/50
Backup formatsBackup formatsplain
Safe copy of data directoryNot good with multiple tablespaces
tarDestination still a directoryEach tablespace gets one file
base.tar
![Page 18: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/18.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 18/50
Transaction logTransaction logWAL required to restore backupFrom beginning of backup to endIn the log archive, right?
![Page 19: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/19.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 19/50
Including WALIncluding WALAlways use -x or -X to include WAL
Default in 10Makes backup independently consistent
With or without log archiveMay back up WAL twice
Use even with log archive!
![Page 20: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/20.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 20/50
Including WALIncluding WAL-X fetch
Fetches WAL at end of backupCan fail if WAL rotated
-X streamReplicates WAL over secondary connectionFewer failure scenariosDoes not work with tar prior to version 10
-X noneTurn off (10+ only)
![Page 21: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/21.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 21/50
Replication slotsReplication slotspg_basebackup can fall behind on < 10Use replication slot
Don't forget to drop!PostgreSQL 10 uses ephemeral slot
![Page 22: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/22.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 22/50
Backup compressionBackup compressionpg_basebackup -Z
Compression happens in pg_basebackupTar format onlyCPU usageRemote server?
![Page 23: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/23.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 23/50
Transfer compressionTransfer compressionSSL compression
Much harder these daysssh tunneling
Does not work with WAL ssh mydbserver -c "pg_basebackup -Ft -D- -Z9 -Xnone" > backup.tgz
![Page 24: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/24.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 24/50
That's it!That's it!With that, you have backupsThat workAnd are (reasonably) safe
![Page 25: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/25.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 25/50
PITRPITRPoint in time recoveryYou all want itA bit more setting up
![Page 26: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/26.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 26/50
archive_commandarchive_commandTo use PITR, we use log archivinglike this?
archive_command = 'test ! -f /mnt/archivedir/%f && cp %p /mnt/archivedir/%f'
![Page 27: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/27.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 27/50
Don't do that!Don't do that!
![Page 28: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/28.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 28/50
pg_receivewalpg_receivewalRuns on archive serverUses streaming replicationGenerates log archive
![Page 29: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/29.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 29/50
pg_receivewalpg_receivewalMore granular recoverySafe against server restartsCan follow timeline switches on master
![Page 30: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/30.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 30/50
pg_receivewalpg_receivewalAlways use with replication slot
As of 9.4But we said modern..
Backups should block
![Page 31: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/31.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 31/50
pg_receivewalpg_receivewal pg_receivewal -D /log/archive -h master -S backup
Ensure it's restarted!
![Page 32: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/32.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 32/50
Backup retentionBackup retentionHow long to keep around?What granularity?...
![Page 33: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/33.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 33/50
Backup retentionBackup retentionRecovery needs:
Base backupAll WAL from start to endAll WAL from end to pitr
(that's why we use -x!)
![Page 34: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/34.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 34/50
Backup retentionBackup retentionfind is o�en enoughDelete logs older than X, base older than Y
Safe if -x was used! #!/bin/bash find /var/backups/basebackup -type f -mtime +30 -print0 | xargs -0 -r /bin/rm find /var/backups/wal -type f -mtime +7 -print0 | xargs -0 -r /bin/rm
![Page 35: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/35.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 35/50
Not enough?Not enough?Handles the simple casesBut has limitationsParticularly in management
![Page 36: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/36.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 36/50
Other toolsOther toolspgBackRestBarman
![Page 37: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/37.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 37/50
pgBackRestpgBackRestBackup schedulingLog archivingRetention managementMulti-serverRestore shortcutsObsessive validation
![Page 38: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/38.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 38/50
pgBackRestpgBackRestDeveloped by CrunchyDataPerl
Moving to CMIT licensessh but not rsync
![Page 39: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/39.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 39/50
pgBackRestpgBackRestCustom protocolParallel backups (compression)Full/Differential/Incremental
Segment basedDelta restore
![Page 40: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/40.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 40/50
pgBackRestpgBackRestValidates checksumsChecksums backups
Every time
![Page 41: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/41.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 41/50
pgBackRestpgBackRestNo pg_receivewal support
YetNo Windows support
Yet
![Page 42: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/42.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 42/50
BarmanBarmanBackup schedulingLog archivingRetention managementMulti-serverRestore shortcuts
![Page 43: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/43.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 43/50
BarmanBarmanDeveloped by 2ndQuadrantPythonGPLv3Primarily ssh+rsync
1.6 learned about pg_receivewal2.0 learned about pg_basebackup
Before that, no (safe) concurrent backup support
![Page 44: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/44.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 44/50
What aboutWhat about
Enterprise product XEnterprise product X??
![Page 45: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/45.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 45/50
Enterprise product XEnterprise product Xpg_basebackup
Run as pre-backup commandOptionally clean up in post-backup
pgbackrest/barmanTo diskLet backup so�ware take it form there
![Page 46: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/46.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 46/50
SummarySummary
![Page 47: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/47.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 47/50
Don't roll your own!Don't roll your own!
![Page 48: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/48.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 48/50
Don't roll your ownDon't roll your ownToo many pitfallsBoth base backups and archivingBackups are too important!
![Page 49: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/49.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 49/50
Don't roll your ownDon't roll your ownPrimary choice
Built-in (pg_basebackup)If it's enough
Secondary choicepgBackRestBarman
Tertiary choiceRestart from top of slide
![Page 50: the Modern Way PostgreSQL Backups - Hagander Backups... · 3/ 25/ 2019 P o stgre SQL Ba ck ups the M o de rn Wa y lo ca lho st: 9999/ ?print- pdf / # / 10/ 50 Physical backups Bas](https://reader034.fdocuments.in/reader034/viewer/2022042300/5ecb3903cdee0f38d742af69/html5/thumbnails/50.jpg)
3/25/2019 PostgreSQL Backups the Modern Way
localhost:9999/?print-pdf/#/ 50/50
Thank you!Thank you!Magnus Hagander
[email protected] @magnushagander
https://www.hagander.net/talks/
This material is licensed