Pgbackrest Integration with Patroni

In order for patroni and pgbackrest to work together, pgbackrest has to be installedfirst on pgbr and set as a backup server.Install pgbackrest in all database servers and pgbr should be accessed without apassword with the postgres user For pgbackrest installation steps, you can review the chapter 11.A backup is taken from the primary server, Pgbackrest Integration with Patroni

Postgresql Installation and Settings

The gnupg package is needed to avoid getting errors about security keys duringinstallation. In the first step, we install this package.In the second step, we create the pgdg.list file in the repositor directory andprovide postgresql link.Then we enter the security key, update the package list and install. Note: If you want to install a different Postgresql Installation and Settings

Debian 11 Linux Installation

Oracle Enterprise Linux, Centos Scientific Linux editions are based on Redhat. The RPMpackages, commands etc. they use are commands mostly similar.Ubuntu and Mint are Debian-based Linux systems. Commands etc. are mostly similar. You can use any virtualization platform (VirtualBox, VMware workstation/ESX, Proxmoxetc.) for installation. The manual will use VirtualBox (you can download and install it Debian 11 Linux Installation

Crontab

Since Postgresql does not have an embedded scheduler, this need is solved with pg_cron and pgagent extensions or with crontab at the operating system level. SQL to be executed, function procedure etc. The codes can be written in Linux bashscript and scheduled with crontab, the embedded scheduler of the Linux operatingsystem. Example Script vim /var/lib/postgresql/scripts/instest.sh Crontab

pg_cron

Using pg_cron has the same logic as cron on Unix/Linux systems.15 03 * * * → Means 03:15 every night. First, the running postgresql version is checked and the appropriate version of pg_cron is installed.shared_preload_libraries is set in the database settings, restarted and theextension is created.A schema named cron comes with the extension. Details about pg_cron

Pgagent

It is an extension of pgadmin, which is the postgres client software. After installing withapt from Postgresql repositories, an extension should also be created in databases. In the client machine ; Connect to postgresql database with pgadmin. The pgAgent Jobs tab will appear belowthe Tablespaces tab. Example By connecting to testdb, a test table is Pgagent

Concepts

Consistent backupIt is the backup taken when all committed transactions are written to the databasefiles, i.e., all the dirty buffer in memory is written to disk.Consistent backup can be taken by stopping the database in smart/fast mode. Inconsistent/Online BackupIt is the backup taken when the data files are not up-to-date, i.e., all committedtransactions have not Concepts

Backup Types

Logical backup is a backup in text format whose content can be read and changed witha text editor. In small builds, logical backup (pg_dump) can be used for builds whererestoring to the previous day isn’t a problem, such as web pages with little movement.However, backup policies should be decided by the institution. Physical backup is Backup Types