Skip to main content

Installing pgBackRest on Linux (RHEL 9 / Rocky / AlmaLinux)

 When you work with PostgreSQL in real environments, one thing becomes very clear very quickly:

Backups are not optional.

It doesn’t matter how stable your database is — failures happen.

  • Disks crash

  • Files get corrupted

  • Someone runs the wrong delete query

  • A patch goes wrong

  • A standby needs rebuilding.

So having a proper backup strategy is not just good practice, it’s survival.

That’s exactly why tools like pgBackRest are so widely used in PostgreSQL production systems.

In this post, I’ll walk through a simple installation of pgBackRest on a Linux server (RHEL 9 / Rocky Linux / AlmaLinux).

Why pgBackRest?

PostgreSQL already provides tools like:

  • pg_dump

  • pg_basebackup

And yes, they work.

But once your database grows, or you start managing HA setups, these tools start feeling limited.

pgBackRest is built for serious PostgreSQL backup requirements.

Some of the reasons it stands out:

  • Supports full, differential, and incremental backups

  • Built-in compression and encryption

  • Handles WAL archiving cleanly

  • Faster backups using parallel processing

  • Supports retention policies automatically

  • Makes restores much easier and safer

In short, pgBackRest is what you want when backups need to be reliable, repeatable, and production-ready.

Installing pgBackRest on Linux

Let’s get into the setup.

Step 1: Enable the EPEL Repository

On RHEL-based systems, pgBackRest depends on a few packages that are available through EPEL.

So the first step is enabling it:

sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm 


Once this is installed, your system can access extra enterprise packages that aren’t available in the default repo.

Step 2: Install libssh2 Dependency

pgBackRest uses libssh2 especially when you work with remote repositories or SSH-based setups.

Install it with:

sudo dnf install -y libssh2


Step 3: Install pgBackRest

Now that the dependency is ready, install pgBackRest itself:

sudo dnf install -y pgBackRest



This will pull the required packages and set up the utility on your server.

Step 4: Verify the Installation

After installation, it’s always a good idea to confirm the command is working:

pgbackrest version


At this stage, you might not see much backup information yet (because the repository isn’t configured), but the command should run successfully.

That confirms pgBackRest is installed properly.

What Makes pgBackRest Better Than Traditional Tools?

This is where pgBackRest really shines compared to the basic PostgreSQL utilities.

Incremental Backups

Unlike pg_basebackup, pgBackRest doesn’t copy the entire database every single time.

It can take:

  • Full backup (first time)

  • Differential backup (changes since last full)

  • Incremental backup (changes since last backup)

This saves a lot of storage and time.

WAL Archiving + Point-in-Time Recovery

pgBackRest handles WAL archiving in a clean way, which makes PITR (Point-in-Time Recovery) much easier.

If something breaks at 2:37 PM, you can restore exactly up to 2:36 PM.

That’s a huge advantage in production.

Compression and Encryption Built In

With pgBackRest you don’t need external scripts for compression.

It supports:

  • Compressed backups

  • Encrypted backups

Which is very useful when backups are stored remotely or in cloud storage.

Parallel Backup and Restore

For large databases, pgBackRest is significantly faster because it supports parallel processing.

Backups that take hours with traditional tools can be completed much quicker.


Backup Validation and Retention Policies

pgBackRest can automatically:

  • Validate backups

  • Expire old backups

  • Maintain retention rules

So you don’t end up with hundreds of old backups eating up storage.

Final Thoughts

If you are working with PostgreSQL seriously — especially in production or HA environments — pgBackRest is one of the best tools you can add to your setup.

Installation is simple, and once configured properly, it gives you:

  • Reliable backups

  • Faster restores

  • PITR support

  • Automation and safety

In the next post, I’ll cover:

✅ Configuring the backup repository
✅ Setting up WAL archiving
✅ Taking the first full backup
✅ Restore testing

Comments

Popular posts from this blog

🚀 Automating Oracle Database Patching with Ansible: A Complete Guide

Oracle database patching has long been the bane of DBAs everywhere. It's a critical task that requires precision, expertise, and often results in extended maintenance windows. What if I told you that you could automate this entire process, reducing both risk and downtime while ensuring consistency across your Oracle estate? 💡 In this comprehensive guide, I'll walk you through a production-ready Ansible playbook that completely automates Oracle patch application using OPatch. Whether you're managing a single Oracle instance or hundreds of databases across your enterprise, this solution will transform your patch management strategy! 🎯 🔥 The Challenge: Why Oracle Patching is Complex Before diving into the solution, let's understand why Oracle patching is so challenging: 🔗 Multiple dependencies : OPatch versions, Oracle Home configurations, running processes ⚠️ Risk of corruption : Incorrect patch application can render databases unusable ⏰ Downtime requirements : Da...

🐳Oracle 19c Database Deployment with Docker

Oracle 19c Database Deployment with Docker 🐳 Oracle 19c Database Deployment with Docker Welcome to this comprehensive guide on deploying, configuring, and managing Oracle 19c Database using Docker containers. This blog will walk you through the entire process from setup to production best practices with practical code examples. Docker provides an excellent way to run Oracle databases in isolated, portable containers, making it easy to deploy and manage Oracle 19c instances for development, testing, and production environments. This approach offers numerous benefits: 🔒 Isolation : Run Oracle in a containerized environment without affecting your host system 🚚 Portability : Easily move your database between different environments 🔄 Reproducibility : Quickly spin up identical database instances ⚡ Resource Efficiency : Use Docker's resource management capabilities to control CPU, memory, and stor...

Oracle Enterprise Manager: A Step-by-Step Guide to Agent Patching

Keeping your Oracle Enterprise Manager (OEM) agents up-to-date is crucial for maintaining system security and performance. In this blog post, we'll walk through the complete process of applying patches to OEM agents using the Enterprise Manager interface. This guide is suitable for database administrators and IT professionals who manage Oracle environments. Prerequisites Before starting the patching process, ensure you have: Administrator access to Oracle Enterprise Manager The latest patch files downloaded from Oracle Support A maintenance window scheduled for your target systems The Patching Process Step 1: Navigate to Patches & Updates Begin by accessing the Enterprise Manager console and navigating to the Enterprise → Patches & Updates section. This is your central hub for all patching operations. Step 2: Upload the Latest Patch Click the UPLOAD button in the interface Select the patch file from your local system Wait for the upload process to complete ...