SlideShare a Scribd company logo
Advanced PostgreSQL
backup & recovery
methods
Anastasia Lubennikova
Postgres@CERN 2020
1
Agenda
- Why backup?
- What is a good backup tool?
- Overview of advanced backup features
- Overview of PostgreSQL backup tools
Spoiler: this talk doesn’t contain any benchmarks.
2
Why do you need a backup?
- To restore the database after an accident
- hardware failure
- software bug
- human error
- To set up a new replica
- To create a test environment
- To inspect data from the past
3
What are the options?
- replica is not a backup
- dump a.k.a. “logical backup”
- storage snapshots
- pg_basebackup
- set of custom scripts
- PostgreSQL specific backup tools
4
What makes a good backup tool?
- Convenience
- out-of-box automatization of various routines
- documentation & support
- convenient and stable api
- Performance
- parallel execution
- compression
- incremental & differential backups
- WAL prefetch
5
What backup tools exist?
- Barman
- pgBackRest
- pg_probackup
- WAL-G
- BART
- part of the “EDB Advanced Server”
- requires pg_basebackup
6
Who is who? Barman
- https://www.pgbarman.org/
- 2ndQuadrant
- GPL v 3.0
- Python
- first release: 2011
- Two methods: basebackup & rsync
Notable features:
Synchronous streaming for “zero data loss”.
7
Who is who? pgBackRest
- https://pgbackrest.org/
- Crunchy Data
- MIT License
- C
- first release: 2014
Notable features:
Performance optimizations for large backups.
8
Who is who? pg_probackup
- https://github.com/postgrespro/pg_probackup
- Postgres Professional
- PostgreSQL License
- C
- first release: 2017 (based on pg_arman)
Notable features:
Page-level incremental backups and built-in validation.
9
Who is who? WAL-G
- https://github.com/wal-g/wal-g
- introduced by Citus Data,
now maintained by Yandex Cloud team
- Apache License, Version 2.0
- Go
- first release: 2017 ( “based on” WAL-E)
Notable features:
Out-of-box support for various cloud storages.
10
Feature list
1. Documentation & Support
2. Backup management
3. WAL archive management
4. Incremental backups
5. Compression and parallel execution
6. Remote backup
7. Cloud backup
8. Advanced restore options
9. Backup validation
10. Backup retention
11
1. Documentation & Support
12
Documentation
Barman User guide & command reference.
Great overview of backup architectures
pgBackRest User guide & command reference
pg_probackup User guide & command reference
WAL-G README
13
Installation
Barman Linux packages, Build from source
pgBackRest Linux packages, Build from source
pg_probackup Linux packages, Build from source,
Windows installer
WAL-G Linux binary, Build from source
14
Support: bug fixes
Barman https://github.com/2ndquadrant-it/barman/issues
pgBackRest https://github.com/pgbackrest/pgbackrest/issues
pg_probackup https://github.com/postgrespro/pg_probackup/issues
WAL-G https://github.com/wal-g/wal-g/issues
15
Commercial support
Barman 2ndQuadrant
pgBackRest CrunchyData
pg_probackup Postgres Professional
WAL-G
16
2. Backup management
17
Set up new PostgreSQL instance
Barman server
configuration files
pgBackRest stanza
configuration files
pg_probackup instance
configuration files, set-config command
WAL-G -
config via environment variables
18
Backup information
Barman plain
pgBackRest plain, json
+ postgresql table
pg_probackup plain, json
+ detailed wal archive info
WAL-G plain, json
19
3. WAL archive management
20
WAL archive management
Barman rsync / get-wal
pgBackRest archive-push / archive get
archive-async
pg_probackup archive-push / archive-get
WAL-G wal-push / wal-fetch
wal prefetch
21
Streaming backups
- Recovery Point Objective (RPO):
"maximum targeted period in which data might be lost
from an IT service due to a major incident"
- “RPO = 0” (Zero data loss)
can be achieved by synchronous WAL streaming
- replication slot
prevents the removal of WAL that is not yet received
(PostgreSQL feature)
22
Streaming backups
Barman streaming_archiver (pg_recievewal)
replication slot
pgBackRest
pg_probackup backup --stream
replication slot
WAL-G
23
4. Incremental backups
Full backup includes all data files.
Differential backup contains changes since last full backup.
Incremental backup contains changes since last backup.
24
Incremental backup methods
- DELTA - read everything, backup what changed
- independent method
- read load on data server
- PAGE - scan WAL to determine changed blocks
- requires WAL archive
- minimal load on data server
- PTRACK - remember changed blocks in a map
- requires core patch
- minimal load during backup
25
Incremental backups
Barman file-level incremental (DELTA)
pgBackRest file-level incremental (DELTA)
file-level differential (DELTA)
pg_probackup page-level incremental:
DELTA, PAGE, PTRACK
WAL-G page-level incremental (DELTA)
26
5. Compression and parallel execution
27
6. Remote backup
Barman SSH
pgBackRest SSH
pg_probackup SSH
WAL-G
28
7. Cloud backup
29
Backup to cloud storage
Barman scripts to ship backups to S3
pgBackRest Amazon S3
+ encryption
pg_probackup
WAL-G Amazon S3, Google Cloud Storage,
Azure Storage, Swift Object Storage
+ encryption
30
Extra backup features
- Backup from standby (All tools)
- to reduce load on master data server
- Resume backup (only pgBackRest)
31
8. Advanced restore options. PITR
Restore to a certain moment in time.
32
Point-in-time-recovery
Barman recovery target options
pgBackRest recovery target options
pg_probackup recovery target options
WAL-G
33
Partial restore
Barman
pgBackRest restore selected databases
pg_probackup restore selected databases
WAL-G
34
9. Backup validation
35
Validate backups
Barman DIY with custom hooks
on backup & restore
pgBackRest page checksums on backup
pg_probackup page checksums on backup
validate on demand
check instance
WAL-G
36
10. Backup retention
37
10. Backup retention. Redundancy = 3
38
10. Backup retention. Window = 7 days
39
Retention policy
Barman retention_policy = REDUNDANCY
retention_policy = RECOVERY WINDOW
pgBackRest redundancy
pg_probackup --retention-redundancy
--retention-window
WAL-G redundancy: retain N
window: delete before
40
Backup pinning
Barman
pgBackRest
pg_probackup ttl=0
WAL-G backup-mark
41
Archive retention
Barman
pgBackRest Archive Retention
--repo-retention-archive
pg_probackup delete --expired --wal
--wal-depth=1
WAL-G
42
Backup merging
Save space by merging old incremental backups.
43
Backup merging
Barman
pgBackRest
pg_probackup merge
--merge-expired
WAL-G
44
45
Conclusion
Barman
(rsync)
pgBackRest pg_probackup WAL-G
Support + + + +
Backup management + + + -
WAL management + + + +
Incremental backup + + + +
Compression &
parallel execution
+ + + +
46
Conclusion
Barman
(rsync)
pgBackRest pg_probackup WAL-G
Remote backup + + + +
Cloud backup - + - +
Advanced restore + + + -
Backup validation + + + -
Backup retention + + + +
47

More Related Content

PPTX
PostgreSQL Database Slides
ODP
OpenGurukul : Database : PostgreSQL
PPTX
Apache Flink and what it is used for
PDF
Upgrade from MySQL 5.7 to MySQL 8.0
PDF
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
PDF
pg_proctab: Accessing System Stats in PostgreSQL
PDF
Linux tuning to improve PostgreSQL performance
PDF
Cluster management with Kubernetes
PostgreSQL Database Slides
OpenGurukul : Database : PostgreSQL
Apache Flink and what it is used for
Upgrade from MySQL 5.7 to MySQL 8.0
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
pg_proctab: Accessing System Stats in PostgreSQL
Linux tuning to improve PostgreSQL performance
Cluster management with Kubernetes

What's hot (20)

PDF
Dockerを利用したローカル環境から本番環境までの構築設計
PPTX
Apache Flink Training: System Overview
PDF
The Parquet Format and Performance Optimization Opportunities
PDF
Patroni: Kubernetes-native PostgreSQL companion
PDF
How to Manage Scale-Out Environments with MariaDB MaxScale
PDF
Kubernetes Introduction
PDF
Kubernetes
PPTX
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
PDF
Deep dive into PostgreSQL statistics.
PPT
Introduction to redis
PDF
PostgreSQL Tutorial For Beginners | Edureka
PDF
PostgreSQL Deep Internal
PDF
Apache Bigtop3.2 (仮)(Open Source Conference 2022 Online/Hiroshima 発表資料)
PPTX
OpenStack Glance
PDF
Postgresql database administration volume 1
PDF
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
PPTX
PostgreSQL.pptx
PDF
PostgreSQL Performance Tuning
PPTX
Alasql JavaScript SQL Database Library: User Manual
PDF
Percona XtraDB Cluster
Dockerを利用したローカル環境から本番環境までの構築設計
Apache Flink Training: System Overview
The Parquet Format and Performance Optimization Opportunities
Patroni: Kubernetes-native PostgreSQL companion
How to Manage Scale-Out Environments with MariaDB MaxScale
Kubernetes Introduction
Kubernetes
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Deep dive into PostgreSQL statistics.
Introduction to redis
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Deep Internal
Apache Bigtop3.2 (仮)(Open Source Conference 2022 Online/Hiroshima 発表資料)
OpenStack Glance
Postgresql database administration volume 1
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
PostgreSQL.pptx
PostgreSQL Performance Tuning
Alasql JavaScript SQL Database Library: User Manual
Percona XtraDB Cluster
Ad

Similar to Advanced backup methods (Postgres@CERN) (20)

PDF
Tutorial all pp_pg_admin_backup_restore
PPTX
Backups
PPT
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
PDF
PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBo...
PDF
configuring a warm standby, the easy way
PDF
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
PDF
Workshop 3: JavaScript build tools
PPTX
Data integration with embulk
ODP
Pro PostgreSQL, OSCon 2008
PDF
Out of the Box Replication in Postgres 9.4(pgconfsf)
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
PDF
Out of the box replication in postgres 9.4
PDF
Pitr Made Easy
PDF
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
PPTX
Automating Disaster Recovery PostgreSQL
PDF
Operating PostgreSQL at Scale with Kubernetes
PDF
Bareos Python Plugins Hacking Workshop by Maik Aussendorf & Stephan Duehr
PDF
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PDF
The Accidental DBA
Tutorial all pp_pg_admin_backup_restore
Backups
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBo...
configuring a warm standby, the easy way
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Workshop 3: JavaScript build tools
Data integration with embulk
Pro PostgreSQL, OSCon 2008
Out of the Box Replication in Postgres 9.4(pgconfsf)
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the box replication in postgres 9.4
Pitr Made Easy
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
Automating Disaster Recovery PostgreSQL
Operating PostgreSQL at Scale with Kubernetes
Bareos Python Plugins Hacking Workshop by Maik Aussendorf & Stephan Duehr
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
The Accidental DBA
Ad

More from Anastasia Lubennikova (12)

PDF
PgconfSV compression
PDF
Btree. Explore the heart of PostgreSQL.
PDF
Page compression. PGCON_2016
PDF
Hacking PostgreSQL. Локальная память процессов. Контексты памяти.
PDF
Hacking PostgreSQL. Разделяемая память и блокировки.
ODP
Hacking PostgreSQL. Физическое представление данных
PDF
Hacking PostgreSQL. Обзор исходного кода
PDF
Расширения для PostgreSQL
PDF
Hacking PostgreSQL. Обзор архитектуры.
PDF
Архитектура и новые возможности B-tree
PDF
Indexes don't mean slow inserts.
PDF
Советы для начинающих разработчиков PostgreSQL
PgconfSV compression
Btree. Explore the heart of PostgreSQL.
Page compression. PGCON_2016
Hacking PostgreSQL. Локальная память процессов. Контексты памяти.
Hacking PostgreSQL. Разделяемая память и блокировки.
Hacking PostgreSQL. Физическое представление данных
Hacking PostgreSQL. Обзор исходного кода
Расширения для PostgreSQL
Hacking PostgreSQL. Обзор архитектуры.
Архитектура и новые возможности B-tree
Indexes don't mean slow inserts.
Советы для начинающих разработчиков PostgreSQL

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
top salesforce developer skills in 2025.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
ai tools demonstartion for schools and inter college
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Digital Strategies for Manufacturing Companies
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
history of c programming in notes for students .pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
System and Network Administration Chapter 2
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Nekopoi APK 2025 free lastest update
PDF
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Understanding Forklifts - TECH EHS Solution
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ISO 45001 Occupational Health and Safety Management System
top salesforce developer skills in 2025.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
ai tools demonstartion for schools and inter college
Online Work Permit System for Fast Permit Processing
Digital Strategies for Manufacturing Companies
Operating system designcfffgfgggggggvggggggggg
Softaken Excel to vCard Converter Software.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
history of c programming in notes for students .pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
System and Network Administration Chapter 2
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Nekopoi APK 2025 free lastest update
Odoo Companies in India – Driving Business Transformation.pdf

Advanced backup methods (Postgres@CERN)

  • 1. Advanced PostgreSQL backup & recovery methods Anastasia Lubennikova Postgres@CERN 2020 1
  • 2. Agenda - Why backup? - What is a good backup tool? - Overview of advanced backup features - Overview of PostgreSQL backup tools Spoiler: this talk doesn’t contain any benchmarks. 2
  • 3. Why do you need a backup? - To restore the database after an accident - hardware failure - software bug - human error - To set up a new replica - To create a test environment - To inspect data from the past 3
  • 4. What are the options? - replica is not a backup - dump a.k.a. “logical backup” - storage snapshots - pg_basebackup - set of custom scripts - PostgreSQL specific backup tools 4
  • 5. What makes a good backup tool? - Convenience - out-of-box automatization of various routines - documentation & support - convenient and stable api - Performance - parallel execution - compression - incremental & differential backups - WAL prefetch 5
  • 6. What backup tools exist? - Barman - pgBackRest - pg_probackup - WAL-G - BART - part of the “EDB Advanced Server” - requires pg_basebackup 6
  • 7. Who is who? Barman - https://www.pgbarman.org/ - 2ndQuadrant - GPL v 3.0 - Python - first release: 2011 - Two methods: basebackup & rsync Notable features: Synchronous streaming for “zero data loss”. 7
  • 8. Who is who? pgBackRest - https://pgbackrest.org/ - Crunchy Data - MIT License - C - first release: 2014 Notable features: Performance optimizations for large backups. 8
  • 9. Who is who? pg_probackup - https://github.com/postgrespro/pg_probackup - Postgres Professional - PostgreSQL License - C - first release: 2017 (based on pg_arman) Notable features: Page-level incremental backups and built-in validation. 9
  • 10. Who is who? WAL-G - https://github.com/wal-g/wal-g - introduced by Citus Data, now maintained by Yandex Cloud team - Apache License, Version 2.0 - Go - first release: 2017 ( “based on” WAL-E) Notable features: Out-of-box support for various cloud storages. 10
  • 11. Feature list 1. Documentation & Support 2. Backup management 3. WAL archive management 4. Incremental backups 5. Compression and parallel execution 6. Remote backup 7. Cloud backup 8. Advanced restore options 9. Backup validation 10. Backup retention 11
  • 12. 1. Documentation & Support 12
  • 13. Documentation Barman User guide & command reference. Great overview of backup architectures pgBackRest User guide & command reference pg_probackup User guide & command reference WAL-G README 13
  • 14. Installation Barman Linux packages, Build from source pgBackRest Linux packages, Build from source pg_probackup Linux packages, Build from source, Windows installer WAL-G Linux binary, Build from source 14
  • 15. Support: bug fixes Barman https://github.com/2ndquadrant-it/barman/issues pgBackRest https://github.com/pgbackrest/pgbackrest/issues pg_probackup https://github.com/postgrespro/pg_probackup/issues WAL-G https://github.com/wal-g/wal-g/issues 15
  • 16. Commercial support Barman 2ndQuadrant pgBackRest CrunchyData pg_probackup Postgres Professional WAL-G 16
  • 18. Set up new PostgreSQL instance Barman server configuration files pgBackRest stanza configuration files pg_probackup instance configuration files, set-config command WAL-G - config via environment variables 18
  • 19. Backup information Barman plain pgBackRest plain, json + postgresql table pg_probackup plain, json + detailed wal archive info WAL-G plain, json 19
  • 20. 3. WAL archive management 20
  • 21. WAL archive management Barman rsync / get-wal pgBackRest archive-push / archive get archive-async pg_probackup archive-push / archive-get WAL-G wal-push / wal-fetch wal prefetch 21
  • 22. Streaming backups - Recovery Point Objective (RPO): "maximum targeted period in which data might be lost from an IT service due to a major incident" - “RPO = 0” (Zero data loss) can be achieved by synchronous WAL streaming - replication slot prevents the removal of WAL that is not yet received (PostgreSQL feature) 22
  • 23. Streaming backups Barman streaming_archiver (pg_recievewal) replication slot pgBackRest pg_probackup backup --stream replication slot WAL-G 23
  • 24. 4. Incremental backups Full backup includes all data files. Differential backup contains changes since last full backup. Incremental backup contains changes since last backup. 24
  • 25. Incremental backup methods - DELTA - read everything, backup what changed - independent method - read load on data server - PAGE - scan WAL to determine changed blocks - requires WAL archive - minimal load on data server - PTRACK - remember changed blocks in a map - requires core patch - minimal load during backup 25
  • 26. Incremental backups Barman file-level incremental (DELTA) pgBackRest file-level incremental (DELTA) file-level differential (DELTA) pg_probackup page-level incremental: DELTA, PAGE, PTRACK WAL-G page-level incremental (DELTA) 26
  • 27. 5. Compression and parallel execution 27
  • 28. 6. Remote backup Barman SSH pgBackRest SSH pg_probackup SSH WAL-G 28
  • 30. Backup to cloud storage Barman scripts to ship backups to S3 pgBackRest Amazon S3 + encryption pg_probackup WAL-G Amazon S3, Google Cloud Storage, Azure Storage, Swift Object Storage + encryption 30
  • 31. Extra backup features - Backup from standby (All tools) - to reduce load on master data server - Resume backup (only pgBackRest) 31
  • 32. 8. Advanced restore options. PITR Restore to a certain moment in time. 32
  • 33. Point-in-time-recovery Barman recovery target options pgBackRest recovery target options pg_probackup recovery target options WAL-G 33
  • 34. Partial restore Barman pgBackRest restore selected databases pg_probackup restore selected databases WAL-G 34
  • 36. Validate backups Barman DIY with custom hooks on backup & restore pgBackRest page checksums on backup pg_probackup page checksums on backup validate on demand check instance WAL-G 36
  • 38. 10. Backup retention. Redundancy = 3 38
  • 39. 10. Backup retention. Window = 7 days 39
  • 40. Retention policy Barman retention_policy = REDUNDANCY retention_policy = RECOVERY WINDOW pgBackRest redundancy pg_probackup --retention-redundancy --retention-window WAL-G redundancy: retain N window: delete before 40
  • 42. Archive retention Barman pgBackRest Archive Retention --repo-retention-archive pg_probackup delete --expired --wal --wal-depth=1 WAL-G 42
  • 43. Backup merging Save space by merging old incremental backups. 43
  • 45. 45
  • 46. Conclusion Barman (rsync) pgBackRest pg_probackup WAL-G Support + + + + Backup management + + + - WAL management + + + + Incremental backup + + + + Compression & parallel execution + + + + 46
  • 47. Conclusion Barman (rsync) pgBackRest pg_probackup WAL-G Remote backup + + + + Cloud backup - + - + Advanced restore + + + - Backup validation + + + - Backup retention + + + + 47