BART is the backup and recovery tool for EDB . BART is not supported by EDB Postgres Advanced Server or PostgreSQL version 14 and later. EDB strongly recommends you move to Barman or pgBackRest as your backup recovery tool.

 

Step 1: Install BART TOOL

Install BART TOOL

 

Install the BART tool with the above links from page

 

https://www.enterprisedb.com/get-started login and click on “get started”

Go to “Backup and RECOVERY Tool” 🡪choose Linux x86-64 (RPM) 🡪access repo

 

Choose the options as below

Install the BART tool with the above links from page

 

-bash-4.2$ cd /usr/edb/bart/bin 

-bash-4.2$ ls

bart  bart-scanner

BART tool works with PG_Basebackup, so we need to do the pre-requisites for the same.

 

-bash-4.2$ cd /var/lib/edb/as13/data

-bash-4.2$ vi pg_hba.conf  (set ip address as below)

 

# IPv4 local connections:

host    all             all             192.168.1.112/32        trust

 

# Allow replication connections from localhost, by a user with the

# replication privilege.

host    replication     all             192.168.1.112/32        trust

 

-bash-4.2$ vi postgresql.conf

 

listen_addresses = ‘*’

port = 5444

wal_level = replica

full_page_writes = on

wal_log_hints = on

archive_mode = on

archive_command = ‘cp %p /var/lib/edb/as13/arch_13/%f’

max_wal_senders = 10

max_replication_slots = 10

log_statement = ‘all’

log_destination = ‘stderr’

logging_collector = on

log_directory = ‘log’

 

-bash-4.2$ cd /usr/edb/bart/etc

-bash-4.2$ ls

bart.cfg.sample

-bash-4.2$ cp -rf bart.cfg.sample bart.cfg

-bash-4.2$ ls

bart.cfg  bart.cfg.sample

-bash-4.2$ vi bart.cfg

 

[BART]

bart_host= [email protected]    (user @ipaddress)

backup_path = /opt/backups

pg_basebackup_path = /usr/edb/as13/bin/pg_basebackup

logfile = /tmp/bart.log

scanner_logfile = /tmp/bart_scanner.log

thread_count = 5

 

[KRISHNA] (specify any name for server)

host = 192.168.1.112

port = 5444

user = enterprisedb (username)

cluster_owner = <cluster_owner>

description = “EPAS 11 Server”

allow_incremental_backups = enabled

archive_command = ‘cp %p %a/%f’

xlog_method = stream

 

we need to set the archive_command and xlog_method as above for the proper backup. 

In the above settings we can see “backup_path = /opt/backups” , so we need to create a folder- backups in the opt location

-bash-4.2$ cd /opt

-bash-4.2$ ls

 rh  VBoxGuestAdditions-6.1.34

 

-bash-4.2$ mkdir backups

-bash-4.2$ chown -R enterprisedb. Backups

-bash-4.2$ chmod 700 backups

-bash-4.2$ ls -lrt

total 4

drwxr-xr-x. 2 root         root            6 Aug 25  2018 rh

drwxr-xr-x. 8 root         root         4096 Sep 13 17:59 VBoxGuestAdditions-6.1.34

drwx——. 3 enterprisedb enterprisedb   21 Sep 15 10:04 backups

 

edb=# create table tree(id int, name text);

CREATE TABLE

edb=# insert into tree values(generate_series(1,1000), ‘abc’);

INSERT 0 1000

edb=# insert into tree values(generate_series(1,1000), ‘xyz’);

INSERT 0 1000

edb=# select pg_switch_wal;

 pg_switch_wal 

—————

 0/C000000

(1 row)

 

edb=# select pg_switch_wal;

 pg_switch_wal 

—————

 0/C000000

(1 row)

 

edb=# select pg_switch_wal;

 pg_switch_wal 

—————

 0/C000000

(1 row)

-bash-4.2$ cd /usr/edb/bart/bin

-bash-4.2$ cd /usr/edb/bart/etc

-bash-4.2$ cd ..

-bash-4.2$ cd bin

-bash-4.2$ ./bart -c /usr/edb/bart/etc/bart.cfg BACKUP -s KRISHNA -Fp –backup-name 15_sep_2

INFO:  DebugTarget – getVar(checkDiskSpace.bytesAvailable)

INFO:  new backup identifier generated 1663224984147

INFO:  creating 5 harvester threads

NOTICE:  all required WAL segments have been archived

INFO:  backup completed successfully

INFO:  

BART VERSION: 2.6.2

BACKUP DETAILS:

BACKUP STATUS: active

BACKUP IDENTIFIER: 1663224984147

BACKUP NAME: 15_sep_2

BACKUP PARENT: none

BACKUP LOCATION: /opt/backups/krishna/1663224984147

BACKUP SIZE: 52.73 MB

BACKUP FORMAT: plain

BACKUP TIMEZONE: Asia/Kolkata

XLOG METHOD: stream

BACKUP CHECKSUM(s): 0

TABLESPACE(s): 0

START WAL LOCATION: 00000001000000000000000D

BACKUP METHOD: streamed

BACKUP FROM: master

START TIME: 2022-09-15 12:26:24 IST

STOP TIME: 2022-09-15 12:26:27 IST

TOTAL DURATION: 3 sec(s)

 

-bash-4.2$ ./bart -c /usr/edb/bart/etc/bart.cfg SHOW-BACKUPS -s KRISHNA

 SERVER NAME   BACKUP ID       BACKUP NAME   BACKUP PARENT   BACKUP TIME               BACKUP SIZE   WAL(s) SIZE   WAL FILES   STATUS  

                                                                                                                                       

 krishna       1663224984147   15_sep_2      none            2022-09-15 12:26:27 IST   52.73 MB      0.00 bytes    0           active  

 krishna       1663217033750   15_sep        none            2022-09-15 10:14:03 IST   52.01 MB      0.00 bytes    0           active  

 krishna       1663216453186   14_sep        none            2022-09-15 10:04:18 IST   51.90 MB      0.00 bytes    0           active  

 

Before restoring we need to create a folder for restoring

 

-bash-4.2$ cd /var/lib/edb

-bash-4.2$ mkdir restore

-bash-4.2$ chown -R enterprisedb. Restore

-bash-4.2$ chmod 700 restore

 

For PITR recovery we need to know the time, we can either note the time while creating /dropping table or follow below steps and choose anytime from the file

 

-bash-4.2$ cd /var/lib/edb/as13/data/

-bash-4.2$ cd log

-bash-4.2$ ls

edb-2022-09-15_000000.log  edb-2022-09-15_120840.log

-bash-4.2$ cat edb-2022-09-15_120840.log

-bash-4.2$ ./bart -c /usr/edb/bart/etc/bart.cfg RESTORE -s KRISHNA -i “1663224984147” -p /var/lib/edb/restore -g ‘2022-09-15 12:25:27’

INFO:  restoring backup ‘1663224984147’ of server ‘krishna’

INFO:  base backup restored

INFO:  writing recovery settings to postgresql.auto.conf

INFO:  WAL file(s) will be streamed from the BART host

INFO:  archiving is disabled

INFO:  permissions set on $PGDATA

INFO:  restore completed successfully

 

PITR completed

 

******for normal recovery

-bash-4.2$ ./bart -c /usr/edb/bart/etc/bart.cfg RESTORE -s KRISHNA -i “1663224984147” -p /var/lib/edb/restore