SlideShare a Scribd company logo
Database Dumps
and Backups
Karen Jex
February 2021
Who am I?
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
3
Agenda
• Why Take Backups?
• Why do we need to Recover?
• What are our Recovery Requirements?
• Backup Methods
• Backup Strategy
• Backup and Recovery Tools
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
4
Why Take Backups?
• Safeguard critical business data
• Recover from database failure
• Recovery strategy
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
5
Practice your disaster recovery
• The only way to be sure that a backup
can be restored is by restoring it
• If you need to restore a database,
it will be an emergency
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
6
Why do we need to Recover?
• Database server crash
• Storage array failure
• Batch process incorrectly modified data
• Human error (or willful destruction)
• Corrupted data file
• Creating development/test databases
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
7
What are our Recovery Requirements?
• Maximum Permitted Data Loss (RPO)
• Maximum Time to Recover (RTO)
• Backup Retention
Backups aren’t
the whole story
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
9
Physical Database Backup
• Offline
• Online
• Continuous archiving
• Storage snapshots
Backup Methods
Logical Database Backup
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
10
Physical Database Backups
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
11
Physical Database Backups
Advantages Disadvantages
• Generally faster to backup/restore from
than logical backup
• Allows PITR (if WALs are archived)
• Full or incremental backups
• Lack of flexibility
(backup/restore entire database cluster)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
12
Offline Backups
(Physical Database Backups)
• Shut down database cluster
• Copy database files
• Start up database cluster
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
13
Advantages Disadvantages
• Any file copy tool can be used
• No need to back up associated WAL files
• Database unavailable during the backup
• PITR is not possible
Offline Backups
(Physical Database Backups)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
14
• WAL = write-ahead log
• wal_level : minimal, replica (default) or logical
• archive_mode: off, on or always
• archive_command
WAL files
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
15
• Tell PostgreSQL you’re starting a backup
• Copy the database files
• Copy the WAL files
• Tell PostgreSQL you’ve finished the backup
Online Backups
(Physical Database Backups)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
16
Advantages Disadvantages
• Database available during backup • WAL files must be backed up
• WAL parameters must be set correctly
Online Backups
(Physical Database Backups)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
17
• All WAL files are backed up
• Allows PITR
Continuous Archiving
(Physical Database Backups)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
18
Storage Snapshots
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
19
Storage Snapshots
• Consistent snapshot of the filesystem
• WAL files must be backed up
• Perform CHECKPOINT just before the snapshot
• Checkpoints of FS containing WAL and each tablespace must be simultaneous
• TEST
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
20
Logical Database Backups
my_db.dump
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
21
Logical Database Backups
Advantages Disadvantages
• Flexibility
• Cross-version compatibility
• Slower restore than from physical
backup
• No PITR
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
22
Comparison of Backup Methods
Allows point in
time recovery
Database available
during backup
Allows backup of
individual objects
Offline Backup
Online Backup ✔
Continuous archiving ✔ ✔
Logical Backup/Dump ✔ ✔
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
23
Backup Strategy
• Backup method
• Frequency of backups
• Full or incremental backups
• Retention period
Backup and
Recovery Tools
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
25
• Point in time recovery (PITR)
• Central backup architecture
• Scheduling
• Backup Catalogue
• Management of Backup and WAL files
Requirements of a Backup/Recovery Tool
• WAL archiving
• Monitoring and alerting
• Compression
• Incremental Backups
• Backup/restore of individual objects
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
26
Requirements of a Backup/Recovery Tool
Point in time recovery (PITR)
Sun Mon Tue Wed Thu Fri Sat
Backup 03:00 Batch 05:00 Backup 03:00 Backup 03:00 Batch 05:00
OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00
Batch 22:00 Batch 22:00
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
27
Requirements of a Backup/Recovery Tool
Central Backup Architecture
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
28
Requirements of a Backup/Recovery Tool
Scheduling Backup
Catalogue
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
29
Requirements of a Backup/Recovery Tool
Management of Backup and WAL files WAL Archiving
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
30
Requirements of a Backup/Recovery Tool
Monitoring and Alerting Backup/Restore selected
objects
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
31
Requirements of a Backup/Recovery Tool
Compression Incremental Backups
Backup and
Recovery Tools
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
33
Backup and Recovery Tools
Physical Backups Logical Backups
• pg_basebackup
• BART
• Barman
• pgBackRest
• pg_dump
• pg_dumpall
• pg_restore
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
34
No Backup Tool?
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
35
Custom Scripts
https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
36
pg_basebackup 1/2
https://www.postgresql.org/docs/current/app-pgbasebackup.html
• Does not affect other clients to the database
• Can be used for point-in-time recovery
• makes a binary copy of the database cluster files
• Puts system in and out of backup mode
• Backs up entire database cluster
• does not manage a backup library
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
37
pg_basebackup 2/2
# pg_basebackup -h mydbserver -z -D /my/backup/location/data
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
38
BART (EDB Backup and Recovery Tool) 1/2
EDB BART 2.6.1 User Guide
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
39
BART
2/2
# bart backup -s <server_name>
# bart restore -s <server_name>
# bart show-backups -s <server_name>
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
40
Barman 1/2
http://docs.pgbarman.org
● Remote backup and restore of multiple servers
● backup catalogs
● incremental backup
● retention policies
● archiving and compression of WAL files and backups
● rsync or PostgreSQL protocol
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
41
Barman 2/2
# barman backup <server_name>
# barman recover <server_name>
# barman list-backup <server_name>
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
42
pgBackRest 1/2
https://pgbackrest.org/
• Parallel Backup & Restore
• Local or Remote Operation
• Full, Incremental, & Differential Backups
• Backup Rotation & Archive Expiration
• Delta Restore
• Parallel, Asynchronous WAL Push & Get
• Tablespace & Link Support
• Encryption
• Limit restore to specific databases
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
43
pgBackRest 2/2
# pgbackrest stanza=<server_name> backup
# pgbackrest stanza=<server_name> restore
# pgbackrest stanza=<server_name> info
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
44
BART/BARMAN/pgBackRest
Common Architecture/Setup
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
45
• Create DB superuser for backups
• Create OS user for backups
• Allow DB connections from the backup server (pg_hba.conf )
• Allow passwordless connections between DB server and backup server
• Allow passwordless connection to DB from backup server
BART/BARMAN/pgBackRest
Common Architecture/Setup
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
46
# backup_config_file
[global section]
backup location
database user
…
[server_name section]
hostname
data directory
…
BART/BARMAN/pgBackRest
Common Architecture/Setup
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
47
BART/BARMAN/pgBackRest
Common Architecture/Setup
/backup_home
server_name
archived_wals
backups
…
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
48
pg_dump
https://www.postgresql.org/docs/current/app-pgdump.html
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
49
pg_dump
https://www.postgresql.org/docs/current/app-pgdump.html
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
50
pg_dump
-F (--format)
c (custom)
d (directory)
t (tar)
-n schema
-t table
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
51
pg_dumpall
https://www.postgresql.org/docs/current/app-pg-dumpall.html
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
52
pg_restore
https://www.postgresql.org/docs/current/app-pgrestore.html
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
53
Comparison of Backup and Recovery Tools
PITR Scheduling
Management of
backup files
WAL archiving Monitoring
Centralised
architecture
BART ✔ via PEM ✔ ✔ via PEM ✔
Barman ✔ ✔ ✔ ✔ ✔ ✔
pgBackRest ✔ ✔ ✔ ✔
pg_dump
pg_dumpall
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
54
Comparison of Backup and Recovery Tools
Compression
Incremental
backups
Specific database /
schema / table
Global objects
Cross-version
compatibility
BART ✔ ✔ ✔
Barman ✔ ✔ ✔
pgBackRest ✔ ✔ Specific database ✔
pg_dump ✔ ✔ ✔
pg_dumpall ✔ ✔ ✔
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
55
Conclusions
• There is a vast array of different backup/export methods
and tools available but they all serve one main purpose,
and that is to support your recovery strategy.
• It is important to determine your recovery requirements
before implementing the backup strategy that fits your
specific needs.
• Your backup strategy may involve one or more of the
methods and tools that we have discussed.
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
56
Questions

More Related Content

What's hot (20)

PPTX
Best Practices in Security with PostgreSQL
EDB
 
PDF
Best Practices & Lessons Learned from Deployment of PostgreSQL
EDB
 
PDF
EDB & ELOS Technologies - Break Free from Oracle
EDB
 
PPTX
How to Design for Database High Availability
EDB
 
PDF
Using PEM to understand and improve performance in Postgres: Postgres Tuning ...
EDB
 
PPTX
PostgreSQL as a Strategic Tool
EDB
 
PPTX
Public Sector Virtual Town Hall: High Availability for PostgreSQL
EDB
 
PPTX
An overview of reference architectures for Postgres
EDB
 
PDF
Why Care Risk Choose PostgreSQL
EDB
 
PPTX
Overcoming write availability challenges of PostgreSQL
EDB
 
PPTX
Migration DB2 to EDB - Project Experience
EDB
 
PPTX
Replacing Oracle with EDB Postgres
EDB
 
PPTX
Migrate Today: Proactive Steps to Unhook from Oracle
EDB
 
PDF
Best Practices in Security with PostgreSQL
EDB
 
PDF
Making your PostgreSQL Database Highly Available
EDB
 
PPTX
PostgreSQL as a Strategic Tool
EDB
 
PDF
Cloud Native PostgreSQL - APJ
EDB
 
PPTX
Webinar: Managing Postgres at Scale
EDB
 
PPTX
New and Improved Features in PostgreSQL 13
EDB
 
PPTX
PostgreSQL to Accelerate Innovation
EDB
 
Best Practices in Security with PostgreSQL
EDB
 
Best Practices & Lessons Learned from Deployment of PostgreSQL
EDB
 
EDB & ELOS Technologies - Break Free from Oracle
EDB
 
How to Design for Database High Availability
EDB
 
Using PEM to understand and improve performance in Postgres: Postgres Tuning ...
EDB
 
PostgreSQL as a Strategic Tool
EDB
 
Public Sector Virtual Town Hall: High Availability for PostgreSQL
EDB
 
An overview of reference architectures for Postgres
EDB
 
Why Care Risk Choose PostgreSQL
EDB
 
Overcoming write availability challenges of PostgreSQL
EDB
 
Migration DB2 to EDB - Project Experience
EDB
 
Replacing Oracle with EDB Postgres
EDB
 
Migrate Today: Proactive Steps to Unhook from Oracle
EDB
 
Best Practices in Security with PostgreSQL
EDB
 
Making your PostgreSQL Database Highly Available
EDB
 
PostgreSQL as a Strategic Tool
EDB
 
Cloud Native PostgreSQL - APJ
EDB
 
Webinar: Managing Postgres at Scale
EDB
 
New and Improved Features in PostgreSQL 13
EDB
 
PostgreSQL to Accelerate Innovation
EDB
 

Similar to Database Dumps and Backups (20)

PDF
Postgres Point-in-Time Recovery
EDB
 
PPTX
Beginners Guide to High Availability for Postgres
EDB
 
PPTX
An overview of reference architectures for Postgres
EDB
 
PDF
PostgreSQL continuous backup and PITR with Barman
EDB
 
PPTX
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
IDERA Software
 
PPTX
Beginner's Guide to High Availability for Postgres
EDB
 
PDF
C7 engineered data_protection_for_oracle_databases
Dr. Wilfred Lin (Ph.D.)
 
PDF
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
PDF
Best Practices for Becoming an Exceptional Postgres DBA
EDB
 
PDF
Oracle Backup Solutions Overview August 2018
Dan Glasscock
 
PPTX
How to use postgresql.conf to configure and tune the PostgreSQL server
EDB
 
PPTX
Oracle Database 12c para la comunidad GeneXus - Engineered for clouds
GeneXus
 
PPTX
Postgres in production.2014
EDB
 
PDF
Oracle Storage a ochrana dat
MarketingArrowECS_CZ
 
PPTX
zdlra-short-overview-4487391_15-06-24.pptx
KumarGumala
 
PPT
Database backup and recovery basics
Shahed Mohamed
 
PPTX
AUSPC 2013 - Business Continuity Management in SharePoint
Michael Noel
 
PDF
Presentation backup and recovery best practices for very large databases (v...
xKinAnx
 
PDF
Managing Postgres at Scale With Postgres Enterprise Manager
EDB
 
PDF
20618782218718364253 emea12 vldb
Locuto Riorama
 
Postgres Point-in-Time Recovery
EDB
 
Beginners Guide to High Availability for Postgres
EDB
 
An overview of reference architectures for Postgres
EDB
 
PostgreSQL continuous backup and PITR with Barman
EDB
 
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
IDERA Software
 
Beginner's Guide to High Availability for Postgres
EDB
 
C7 engineered data_protection_for_oracle_databases
Dr. Wilfred Lin (Ph.D.)
 
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
Best Practices for Becoming an Exceptional Postgres DBA
EDB
 
Oracle Backup Solutions Overview August 2018
Dan Glasscock
 
How to use postgresql.conf to configure and tune the PostgreSQL server
EDB
 
Oracle Database 12c para la comunidad GeneXus - Engineered for clouds
GeneXus
 
Postgres in production.2014
EDB
 
Oracle Storage a ochrana dat
MarketingArrowECS_CZ
 
zdlra-short-overview-4487391_15-06-24.pptx
KumarGumala
 
Database backup and recovery basics
Shahed Mohamed
 
AUSPC 2013 - Business Continuity Management in SharePoint
Michael Noel
 
Presentation backup and recovery best practices for very large databases (v...
xKinAnx
 
Managing Postgres at Scale With Postgres Enterprise Manager
EDB
 
20618782218718364253 emea12 vldb
Locuto Riorama
 
Ad

More from EDB (20)

PDF
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
EDB
 
PDF
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
EDB
 
PDF
Migre sus bases de datos Oracle a la nube
EDB
 
PDF
EFM Office Hours - APJ - July 29, 2021
EDB
 
PDF
Benchmarking Cloud Native PostgreSQL
EDB
 
PDF
Las Variaciones de la Replicación de PostgreSQL
EDB
 
PDF
NoSQL and Spatial Database Capabilities using PostgreSQL
EDB
 
PDF
Is There Anything PgBouncer Can’t Do?
EDB
 
PDF
Data Analysis with TensorFlow in PostgreSQL
EDB
 
PDF
Practical Partitioning in Production with Postgres
EDB
 
PDF
A Deeper Dive into EXPLAIN
EDB
 
PDF
IOT with PostgreSQL
EDB
 
PDF
A Journey from Oracle to PostgreSQL
EDB
 
PDF
Psql is awesome!
EDB
 
PDF
EDB 13 - New Enhancements for Security and Usability - APJ
EDB
 
PPTX
Comment sauvegarder correctement vos données
EDB
 
PDF
Cloud Native PostgreSQL - Italiano
EDB
 
PDF
Best Practices in Security with PostgreSQL
EDB
 
PDF
EDB Postgres & Tools in a Smart City Project
EDB
 
PDF
All you need to know about CREATE STATISTICS
EDB
 
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
EDB
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
EDB
 
Migre sus bases de datos Oracle a la nube
EDB
 
EFM Office Hours - APJ - July 29, 2021
EDB
 
Benchmarking Cloud Native PostgreSQL
EDB
 
Las Variaciones de la Replicación de PostgreSQL
EDB
 
NoSQL and Spatial Database Capabilities using PostgreSQL
EDB
 
Is There Anything PgBouncer Can’t Do?
EDB
 
Data Analysis with TensorFlow in PostgreSQL
EDB
 
Practical Partitioning in Production with Postgres
EDB
 
A Deeper Dive into EXPLAIN
EDB
 
IOT with PostgreSQL
EDB
 
A Journey from Oracle to PostgreSQL
EDB
 
Psql is awesome!
EDB
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB
 
Comment sauvegarder correctement vos données
EDB
 
Cloud Native PostgreSQL - Italiano
EDB
 
Best Practices in Security with PostgreSQL
EDB
 
EDB Postgres & Tools in a Smart City Project
EDB
 
All you need to know about CREATE STATISTICS
EDB
 
Ad

Recently uploaded (20)

DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 

Database Dumps and Backups

  • 3. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 3 Agenda • Why Take Backups? • Why do we need to Recover? • What are our Recovery Requirements? • Backup Methods • Backup Strategy • Backup and Recovery Tools
  • 4. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 4 Why Take Backups? • Safeguard critical business data • Recover from database failure • Recovery strategy
  • 5. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 5 Practice your disaster recovery • The only way to be sure that a backup can be restored is by restoring it • If you need to restore a database, it will be an emergency
  • 6. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 6 Why do we need to Recover? • Database server crash • Storage array failure • Batch process incorrectly modified data • Human error (or willful destruction) • Corrupted data file • Creating development/test databases
  • 7. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 7 What are our Recovery Requirements? • Maximum Permitted Data Loss (RPO) • Maximum Time to Recover (RTO) • Backup Retention
  • 9. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 9 Physical Database Backup • Offline • Online • Continuous archiving • Storage snapshots Backup Methods Logical Database Backup
  • 10. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 10 Physical Database Backups
  • 11. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 11 Physical Database Backups Advantages Disadvantages • Generally faster to backup/restore from than logical backup • Allows PITR (if WALs are archived) • Full or incremental backups • Lack of flexibility (backup/restore entire database cluster)
  • 12. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 12 Offline Backups (Physical Database Backups) • Shut down database cluster • Copy database files • Start up database cluster
  • 13. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 13 Advantages Disadvantages • Any file copy tool can be used • No need to back up associated WAL files • Database unavailable during the backup • PITR is not possible Offline Backups (Physical Database Backups)
  • 14. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 14 • WAL = write-ahead log • wal_level : minimal, replica (default) or logical • archive_mode: off, on or always • archive_command WAL files
  • 15. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 15 • Tell PostgreSQL you’re starting a backup • Copy the database files • Copy the WAL files • Tell PostgreSQL you’ve finished the backup Online Backups (Physical Database Backups)
  • 16. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 16 Advantages Disadvantages • Database available during backup • WAL files must be backed up • WAL parameters must be set correctly Online Backups (Physical Database Backups)
  • 17. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 17 • All WAL files are backed up • Allows PITR Continuous Archiving (Physical Database Backups)
  • 18. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 18 Storage Snapshots
  • 19. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 19 Storage Snapshots • Consistent snapshot of the filesystem • WAL files must be backed up • Perform CHECKPOINT just before the snapshot • Checkpoints of FS containing WAL and each tablespace must be simultaneous • TEST
  • 20. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 20 Logical Database Backups my_db.dump
  • 21. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 21 Logical Database Backups Advantages Disadvantages • Flexibility • Cross-version compatibility • Slower restore than from physical backup • No PITR
  • 22. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 22 Comparison of Backup Methods Allows point in time recovery Database available during backup Allows backup of individual objects Offline Backup Online Backup ✔ Continuous archiving ✔ ✔ Logical Backup/Dump ✔ ✔
  • 23. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 23 Backup Strategy • Backup method • Frequency of backups • Full or incremental backups • Retention period
  • 25. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 25 • Point in time recovery (PITR) • Central backup architecture • Scheduling • Backup Catalogue • Management of Backup and WAL files Requirements of a Backup/Recovery Tool • WAL archiving • Monitoring and alerting • Compression • Incremental Backups • Backup/restore of individual objects
  • 26. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 26 Requirements of a Backup/Recovery Tool Point in time recovery (PITR) Sun Mon Tue Wed Thu Fri Sat Backup 03:00 Batch 05:00 Backup 03:00 Backup 03:00 Batch 05:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 OLTP 09:00 - 18:00 Batch 22:00 Batch 22:00
  • 27. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 27 Requirements of a Backup/Recovery Tool Central Backup Architecture
  • 28. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 28 Requirements of a Backup/Recovery Tool Scheduling Backup Catalogue
  • 29. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 29 Requirements of a Backup/Recovery Tool Management of Backup and WAL files WAL Archiving
  • 30. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 30 Requirements of a Backup/Recovery Tool Monitoring and Alerting Backup/Restore selected objects
  • 31. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 31 Requirements of a Backup/Recovery Tool Compression Incremental Backups
  • 33. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 33 Backup and Recovery Tools Physical Backups Logical Backups • pg_basebackup • BART • Barman • pgBackRest • pg_dump • pg_dumpall • pg_restore
  • 34. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 34 No Backup Tool?
  • 35. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 35 Custom Scripts https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP
  • 36. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 36 pg_basebackup 1/2 https://www.postgresql.org/docs/current/app-pgbasebackup.html • Does not affect other clients to the database • Can be used for point-in-time recovery • makes a binary copy of the database cluster files • Puts system in and out of backup mode • Backs up entire database cluster • does not manage a backup library
  • 37. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 37 pg_basebackup 2/2 # pg_basebackup -h mydbserver -z -D /my/backup/location/data
  • 38. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 38 BART (EDB Backup and Recovery Tool) 1/2 EDB BART 2.6.1 User Guide
  • 39. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 39 BART 2/2 # bart backup -s <server_name> # bart restore -s <server_name> # bart show-backups -s <server_name>
  • 40. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 40 Barman 1/2 http://docs.pgbarman.org ● Remote backup and restore of multiple servers ● backup catalogs ● incremental backup ● retention policies ● archiving and compression of WAL files and backups ● rsync or PostgreSQL protocol
  • 41. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 41 Barman 2/2 # barman backup <server_name> # barman recover <server_name> # barman list-backup <server_name>
  • 42. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 42 pgBackRest 1/2 https://pgbackrest.org/ • Parallel Backup & Restore • Local or Remote Operation • Full, Incremental, & Differential Backups • Backup Rotation & Archive Expiration • Delta Restore • Parallel, Asynchronous WAL Push & Get • Tablespace & Link Support • Encryption • Limit restore to specific databases
  • 43. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 43 pgBackRest 2/2 # pgbackrest stanza=<server_name> backup # pgbackrest stanza=<server_name> restore # pgbackrest stanza=<server_name> info
  • 44. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 44 BART/BARMAN/pgBackRest Common Architecture/Setup
  • 45. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 45 • Create DB superuser for backups • Create OS user for backups • Allow DB connections from the backup server (pg_hba.conf ) • Allow passwordless connections between DB server and backup server • Allow passwordless connection to DB from backup server BART/BARMAN/pgBackRest Common Architecture/Setup
  • 46. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 46 # backup_config_file [global section] backup location database user … [server_name section] hostname data directory … BART/BARMAN/pgBackRest Common Architecture/Setup
  • 47. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 47 BART/BARMAN/pgBackRest Common Architecture/Setup /backup_home server_name archived_wals backups …
  • 48. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 48 pg_dump https://www.postgresql.org/docs/current/app-pgdump.html
  • 49. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 49 pg_dump https://www.postgresql.org/docs/current/app-pgdump.html
  • 50. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 50 pg_dump -F (--format) c (custom) d (directory) t (tar) -n schema -t table
  • 51. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 51 pg_dumpall https://www.postgresql.org/docs/current/app-pg-dumpall.html
  • 52. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 52 pg_restore https://www.postgresql.org/docs/current/app-pgrestore.html
  • 53. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 53 Comparison of Backup and Recovery Tools PITR Scheduling Management of backup files WAL archiving Monitoring Centralised architecture BART ✔ via PEM ✔ ✔ via PEM ✔ Barman ✔ ✔ ✔ ✔ ✔ ✔ pgBackRest ✔ ✔ ✔ ✔ pg_dump pg_dumpall
  • 54. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 54 Comparison of Backup and Recovery Tools Compression Incremental backups Specific database / schema / table Global objects Cross-version compatibility BART ✔ ✔ ✔ Barman ✔ ✔ ✔ pgBackRest ✔ ✔ Specific database ✔ pg_dump ✔ ✔ ✔ pg_dumpall ✔ ✔ ✔
  • 55. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 55 Conclusions • There is a vast array of different backup/export methods and tools available but they all serve one main purpose, and that is to support your recovery strategy. • It is important to determine your recovery requirements before implementing the backup strategy that fits your specific needs. • Your backup strategy may involve one or more of the methods and tools that we have discussed.
  • 56. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 56 Questions