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

PDF
Remote DBA Service: Powering your DBA needs
 
PDF
Beginner's Guide to High Availability for Postgres
 
PDF
Beginner's Guide to High Availability for Postgres - French
 
PDF
New enhancements for security and usability in EDB 13
 
PPTX
New enhancements for security and usability in EDB 13
 
PDF
Using PEM to understand and improve performance in Postgres: Postgres Tuning ...
 
PPTX
Expert Guide to Migrating Legacy Databases to Postgres
 
PPTX
Automating a PostgreSQL High Availability Architecture with Ansible
 
Remote DBA Service: Powering your DBA needs
 
Beginner's Guide to High Availability for Postgres
 
Beginner's Guide to High Availability for Postgres - French
 
New enhancements for security and usability in EDB 13
 
New enhancements for security and usability in EDB 13
 
Using PEM to understand and improve performance in Postgres: Postgres Tuning ...
 
Expert Guide to Migrating Legacy Databases to Postgres
 
Automating a PostgreSQL High Availability Architecture with Ansible
 

What's hot (20)

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

Similar to Database Dumps and Backups (20)

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

More from EDB (20)

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

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Electronic commerce courselecture one. Pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation theory and applications.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Programs and apps: productivity, graphics, security and other tools
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
MIND Revenue Release Quarter 2 2025 Press Release
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Network Security Unit 5.pdf for BCA BBA.
Electronic commerce courselecture one. Pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation theory and applications.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Programs and apps: productivity, graphics, security and other tools

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