CYBERTEC Logo

pgBackRest to backup PostgreSQL

08.2019 / Category: / Tags: | |

pgBackRest is an open source backup tool for PostgreSQL which offers easy configuration and reliable backups. So if you want to protect your database and create backups easily, pgBackRest is a good solution to make that happen. In this blog, we are going to go through the basic steps of using pgBackRest for full and differential backup of PostgreSQL.

Some of the key features of pgBackRest are:

  1. Parallel backup & restore
  2. Local and remote operations
  3. Full, incremental & differential backups
  4. Backup rotation & archive expiration
  5. Backup integrity
  6. Page checksums
  7. Resume backups
  8. Streaming compression and checksums

 

To read about them more in detail, please visit pgbackrest.org.

Here, we are going to build pgBackRest from the source and install it on the host where a test DB cluster is running.

Installation:

Installing from Debian / Ubuntu packages:

 

For manual installation, download the source on a build host. Please avoid building the source on a production server, as the tools required should not be installed on a production machine:

 

Download pgBackRest Version 2.14:

Install the dependencies and check for 64-bit integers:

 

 

Build pgbackrest package:

Copy from build host to DB host:

Install Perl packages:

pgBackRest config files & directories on DB test host:

Create repository for pgBackRest

Set the Repo path and PostgreSQL cluster directory in the pgbackrest file:

Configure archiving on the PostgreSQL cluster:

Change the following parameters in postgresql.conf:

Create stanza as postgres user:

The stanza-create command must be run on the host where the repository is located to initialize the stanza. It is recommended that the check command be run after stanza-create to ensure archiving and backups are properly configured.

 

Use the info command to get information about the backup

Since we haven't made any backups yet, we will get the following result:

 

 

Backup:

Let's make the first backup. By default, it will be full even if we specify type as differential:

 

 

Now when we run the info command again:

 

Take a differential backup of the cluster

To see the changes, check info:

 

If you want to learn more about how to protect data, check out my blog on PostgreSQL TDE ("Transparent Data Encryption") .

Also if you want to make sure that your database performs well, check out our blog posts on PostgreSQL performance.


In order to receive regular updates on important changes in PostgreSQL, subscribe to our newsletter, or follow us on Twitter, Facebook, or LinkedIn.

0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Luca Ferrari
4 years ago

Great article!
I really love pgbackrest, even if I don't like very much the design of the configuration file with the numbers within parameters (repo1-path, ecc.).

CYBERTEC Logo white
CYBERTEC PostgreSQL International GmbH
Römerstraße 19
2752 Wöllersdorf
Austria

+43 (0) 2622 93022-0
office@cybertec.at

Get the newest PostgreSQL Info & Tools


    This site is protected by reCAPTCHA and the Google Privacy Policy & Terms of Service apply.

    ©
    2024
    CYBERTEC PostgreSQL International GmbH
    phone-handsetmagnifiercrosscross-circle
    1
    0
    Would love your thoughts, please comment.x
    ()
    x
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram