()

Physical PostgreSQL Backup

Is file system-level copy of files that comprise the database cluster can be either Offline or Online mode.


Advantage :

Ā 1) Generally faster to backup and restore.
Ā 2) Allow Point-In-Time-Recovery PITR (If WAL are archived)
Ā 3) Full or Incremental backup.
Ā 4) Will allow DDL during backup.

Disadvantage :
Ā 1) Lack of flexibility:- Backup/Restore entire DB Cluster. Selective restoration options are not possible
Ā 2) Inconsistent backup.

Backup Methods:Ā 


Offline :
Shutdown the DB Cluster – Copy Datafiles – Startup DB Cluster.
Ā  Ā  Ā  Ā  Ā  Ā 
Advantage:-

Ā Any file copy tool can be used to copy datafiles
Ā No need to copy associated WAL files
Disadvantage:Ā 
DatabaseĀ unavailable during backup.
PITR is not possible.


Online :-
Tell PostgreSQL that you are taking a backup – Copy the database files – Copy the Wal files – Tell PostgreSql you have finished the backup.
Ā  Ā  Ā  Ā  Ā  Ā 
Advantage
:-Ā 

DB available during backup

Disadvantage:-
WAL files must be backed up
WAL parameters must be set correctly


Continuous Archiving :-
Extension of Online backup is Continuous archiving
Ā  All WAL files are backed up
Ā  Allow PITR


Storage Snapshots
:-
Is essentially an image of file system at given point of time
Ā  Ā Consistent snapshot of the file system
Ā  WAL files must be backed up
Ā  Perform checkpoint just before the snapshot
Ā  Checkpoint of FS containing WAL and each tablespace must be simultaneous
Ā  Example LVM Snapshot


Tools (Utilities) for Physical Backup :


pg_basebackup:-
Ā  Ā  Ā  Ā Use to take hot backup of postgresql cluster and its is not possible to take backup of the individual database orĀ  Ā  Ā 
Ā  Ā  Ā  Ā database object.

Ā  Ā  Ā  Ā Does not affect other clients to the DB.
Ā  Ā  Ā  Ā Can be used for PITR.
Ā  Ā  Ā  Ā Makes a binary copy of database cluster files.
Ā  Ā  Ā  Ā Put a system in and out of backup mode.
Ā  Ā  Ā  Ā Does not manage the backup library.
Ā  Ā  Ā  Ā Backup is made over a regular PostgreSQL connection and uses the replication protocols.
Ā  Ā  Ā  Ā The connection must be made with a user having replication permission.
Ā  Ā  Ā  Ā The user must be granted explicit permissions in pg_hba.confg
Ā  Ā  Ā  Ā Eg: pg_basebackup -h myserverdb -z -D /my/backup/location

Ā 

pg_BackRest:-
Ā  Ā  Ā  Ā Open Source tool.
Ā  Ā  Ā  Ā Parallel Backup & Restore.
Ā  Ā  Ā  Ā Local & Remote operation.
Ā  Ā  Ā  Ā Full, Incremental & differential backup.
Ā  Ā  Ā  Ā Backup rotation & archive expiration.
Ā  Ā  Ā  Ā Delta restore.
Ā  Ā  Ā  Ā Parallel, Async WAL push and get.
Ā  Ā  Ā  Ā Tablespace & Link support.
Ā  Ā  Ā  Ā Encryption.
Ā  Ā  Ā  Ā Limit restore of a specific database.
Ā  Ā  Ā  Ā Eg : pgbackrest stanza=<server name> backup
Ā  Ā  Ā  Ā Eg : pgbackrest stanza=<server name> restore
Ā  Ā  Ā  Ā Eg : pgbackrest stanza=<server name> info

Ā 

BART (EDB Backup & Recovery Tool):-
Ā  Ā  Ā  Proprietary licensed product by EDB (EnterpriseDB)
Ā  Ā  Ā  Eg :Ā  bart backup -s <server name>
Ā  Ā  Ā  Eg : bart restore -s <server name>
Ā  Ā  Ā  Eg : bart show-backups -s <server name>


Barman (Backup & Recovery Manager):-
Ā  Ā  Ā  Open Source Tool.
Ā  Ā  Ā  Remote backup and restore of multiple Servers.
Ā  Ā  Ā  Backup catalogs.
Ā  Ā  Ā  Incremental backup.
Ā  Ā  Ā  Retention policies.
Ā  Ā  Ā  Archiving and compression of Wal files and backups.
Ā  Ā  Ā  rsync or postgresql protocols.
Ā  Ā  Ā Eg : barman backup <server name>
Ā  Ā  Ā Eg : barman restore <server name>
Ā  Ā  Ā Eg : barman list-backup <server name>

Ā 

Ā 

This document is just for learning purpose and always validate in the LAB environment first before applying in the LIVE environment.


Hope so you like this article
!
Please share your valuable feedback/comments/subscribeĀ and follow us below and don’t forget to click on the bell icon to get the most recent update.Ā Click here to understand more about our pursuit.

Recent articles


Loading

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Jamsher Khan

Hello and welcome to DBsGuru,I’m Jamsher Khan working as Senior Oracle DBA based in KSA-Jeddah, I have working experience in Oracle DBA, SQL Server, MySql, PostgreSQL, Linux, Golden Gate, ODA.Thanks for the visits!Share Learn Grow!

2 thoughts on “Physical PostgreSQL Backup

  1. I am not sure where you are getting your info, but great tߋpic. I need to spend some time learning much moгe or understandіng more.
    Thanks for the great information I was looking for this info for mу mission.

  2. Hi cоlleagues, its wonderful post about teachingand cⲟmpletely explained, keep it սp all
    the time.

Comments are closed.