Introduction
When it comes to backing up PostgreSQL databases, there are several tools available. Three popular ones are pg_basebackup, pgBarman, and pgBackRest. While they all serve the same purpose, they have some significant differences that can impact your backup strategy. In this blog, we’ll explore the differences between these three tools and help you choose the right one for your needs.
pg_basebackup
pg_basebackup is a built-in PostgreSQL utility that allows you to create a full backup of a PostgreSQL database cluster. It works by streaming the contents of the database to a new PostgreSQL instance, creating an exact replica of the original database. This method is known as a logical backup, and it’s the most basic form of backup available.
The advantage of pg_basebackup is that it’s easy to use and comes with PostgreSQL out of the box.
- Full database backup: This creates a full backup of a PostgreSQL database cluster.
- Logical backup: Backs up the data in a logical format that can be used to restore the database to a specific state.
- Built-in PostgreSQL utility: Comes with PostgreSQL out of the box, so no additional installation is needed.
- Easy to use: Simple command-line interface with minimal configuration required.
- Stream-based backup: Backs up the data by streaming it to a new PostgreSQL instance, making it easy to create a new copy of the database.
- Low storage requirements: Since it’s a logical backup, it requires less storage space than physical backups.
It’s worth noting that pg_basebackup is a very basic backup tool, and it lacks many of the advanced features of pgBarman and pgBackRest. While it can create a full backup of a PostgreSQL database cluster, it doesn’t provide features like incremental backups, point-in-time recovery, or replication. Additionally, it doesn’t have any built-in features for managing backups or restoring them, so you’ll need to do that manually. However, for small or simple PostgreSQL setups, pg_basebackup can be a good choice due to its simplicity and low storage requirements.
pgBarman
pgBarman is a backup and recovery tool for PostgreSQL that’s designed to be easy to use and highly scalable. It provides several features that aren’t available in pg_basebackup, such as point-in-time recovery (PITR), incremental backups, and replication.
One of the most significant advantages of pgBarman is that it can manage backups for multiple PostgreSQL servers from a single location. This makes it an ideal choice for organizations with several PostgreSQL instances to manage. Additionally, pgBarman has an easy-to-use web interface that allows you to monitor your backups and restore them quickly if necessary.
pgBarman Features
- Point-in-time recovery (PITR): Allows you to restore your database to a specific point in time.
- Incremental backups: Only backs up changes made since the last backup, reducing backup time and storage space needed.
- Replication: Allows you to replicate your backups to a secondary server for disaster recovery purposes.
- Multiple server management: Can manage backups for multiple PostgreSQL servers from a single location.
- Backup monitoring: Provides an easy-to-use web interface to monitor backup progress and status.
- Backup retention policies: Allows you to set policies for retaining backups based on time or the number of backups.
Feel free to refer to this blog – Setting up and Configuring pgBarman for end-to-end implementation of pgBarman in your production environment.
pgBackRest
pgBackRest is a backup and recovery tool for PostgreSQL that’s designed to be highly efficient and scalable. It’s a relatively new tool, but it’s quickly gaining popularity due to its speed and ease of use. It provides several features that aren’t available in pg_basebackup or pgBarman, such as parallel backup and restore delta backups, and compressed backups.
One of the most significant advantages of pgBackRest is its speed. It can create a full backup of a PostgreSQL database cluster in a matter of minutes, making it an ideal choice for organizations with large databases. Additionally, pgBackRest has an easy-to-use command-line interface that allows you to manage your backups and restore them quickly if necessary.
pgBackRest Backup Types: pgBackRest has 3 backup types:
Full backup: All data in the PostgreSQL Cluster is backed up.
Differential backup: Backup files that have changed from the last full backup.
Incremental backup: Backups the files that have changed from the last backup.
pgBackRest Features
- Parallel backup and restore: Allows you to perform backups and restores in parallel, reducing backup and restore time.
- Delta backups: Only backs up changes made since the last backup, reducing backup time and storage space needed.
- Compressed backups: Compresses backups to reduce storage space needed.
- Highly scalable: Can handle backups for very large databases efficiently.
- Support for S3 and other object stores: Can store backups in S3 or other object stores.
- Archive management: Provides a way to manage PostgreSQL’s archive directory and retain backups for point-in-time recovery.
Feel free to refer to this blog – Setting up and Configuring pgBackRest for end-to-end implementation of pgBackrest in your production environment.
Here’s a comparison of some of the main differences between Barman and pgBackRest:
Feature | pgBarman | pgBackRest |
---|---|---|
Backup method | Full Backups Incremental Backups Streaming method rsync method postgres method | Full Backups Incremental Backups Differential Backups |
Compression | Yes, built-in | Yes, built-in |
Parallelism | Yes, configurable | Yes, Automatic |
Backup concurrency | Limited, single backup at a time | High, multiple backups at the same time |
Restore | Yes, flexible | Yes, more flexible |
Configuration file | /etc/barman/barman.conf | /etc/pgbackrest/pgbackrest.conf |
Point-in-time recovery | Yes, using WAL archives | Yes, using WAL archives |
Conclusion
In conclusion, all three backup tools have their advantages and disadvantages. pg_basebackup is the most basic and easiest to use, but it lacks some of the advanced features of pgBarman and pgBackRest. pgBarman is ideal for organizations with multiple PostgreSQL instances to manage, while pgBackRest is best suited for organizations with large databases that require fast and efficient backups. Ultimately, the tool you choose will depend on your specific needs and requirements.
OpenSource DB offers comprehensive PostgreSQL services that cover everything – migration & infrastructure, Backup, replication & development as well as updates & upgrades. Our scope of services that are not limited to the services listed; it can be extended depending on your specific setup and requirements.
Let us help build your application on the world’s leading object-relational database system and create the best solution for your business. contact us today.
For Business Enquiries Contact
Raviteja Reddy K
Customer Success Manager – OpenSource DB
Hyderabad, India | +91-8886 818 173 | https://opensource-db.com/
https://www.linkedin.com/in/ravi-tej-reddy/
Also, check out our next blog posts about Setting up & Configuring pgBarman & pgBackRest
Leave a Reply