cancel
Showing results for 
Search instead for 
Did you mean: 

[Guide] Getting Started with BART 2.1

EDB Team Member

I wanted to cover some of the basics of using BART and the basic installation process for people who may be using BART for the first time. So what is BART? BART is the Backup And Recovery Tool created by EnterpriseDB to assist with the backup of a community Postgres or EnterpriseDB Advanced Server database. 

 

So where do we start? First, we install BART 2.1, which can be downloaded from our YUM repository (http://yum.enterprisedb.com, under Tools).

The filename should look something like this; it will vary based on version.

 

edb-bart-2.1.0-1.rhel6.x86_64.rpm

 

 

Once you download it, installing is as simple as a single rpm command:

 

> rpm -ivh edb-bart-2.1.0-1.rhel6.x86_64.rpm
Preparing... ########################################### [100%]
1:edb-bart ########################################### [100%]

 

 

NOTE: If you run into errors like this upon running the rpm, please see my related Knowledgebase article: Installing BART 2.1

 

> rpm -ivh edb-bart-2.1.0-1.rhel6.x86_64.rpm
error: Failed dependencies: libboost_chrono-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64 libboost_filesystem-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64 libboost_iostreams-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64 libboost_serialization-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64 libboost_system-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64 libboost_thread-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64 libboost_timer-mt.so.1.48.0()(64bit) is needed by edb-bart-2.1.0-1.rhel6.x86_64

 

Next, you'll need to configure BART for your system. In my situation, I'm setting up a single EnterpriseDB Advanced Server, and I would like to install BART on the same server to back up that server. An installation on community Postgres should look virtually identical. Cross-server configurations are supported, but it is outside of the scope of this guide.

Before we start, we should gather a bit of information to make our lives easier. We need the following information for BART configuration:

  1. The computer user that will be running BART (I will be using "root")
  2. The IP of the computer that will be running BART ( I found that my IP was 172.17.0.2. I am using Docker images for this exercise, so that makes sense)
  3. Where to back up the files (Typically, we use wherever pg_basebackup is, which in my case is /usr/edb/as9.6/bin/pg_basebackup)
  4. The postgres user who will be backing up (I will be using "enterprisedb")
  5. The IP and port of the Postgres server (Since mine is on the same computer, the IP remains the same, 172.17.0.2, and I am on port 5432)

Some commands to help you gather this information:

> whoami
root
>hostname -i
172.17.0.2
> locate pg_basebackup
/usr/edb/as9.6/bin/pg_basebackup
>  psql
psql.bin (9.6.6.11)
Type "help" for help.

edb=# \conninfo
You are connected to database "edb" as user "enterprisedb" via socket in "/tmp" at port "5432".

 

 

We will use this information to configure two files: bart.cfg and pg_hba.conf. bart.cfg doesn't initially exist, but there is a template file that we can use:

>  cp /usr/edb/bart/etc/bart.cfg.sample /usr/edb/bart/etc/bart.cfg

For pg_hba.conf, I added the following line:

> less /var/lib/edb/as9.6/data/pg_hba.conf
host replication enterprisedb 172.17.0.2/32 trust

And in bart.cfg, I changed the following:

> less /usr/edb/bart/etc/bart.cfg
[BART]
bart_host= root@172.17.0.2                                // Added name and IP
backup_path = /opt/backups
pg_basebackup_path = /usr/edb/as9.6/bin/pg_basebackup     // Added the pg_basebackup path
logfile = /tmp/bart.log
scanner_logfile = /tmp/bart_scanner.log
thread_count = 5

[Production]
host = 172.17.0.2                                         // Added IP
port = 5432                                               // Added port 
user = enterprisedb                                       // Added user
cluster_owner = <cluster_owner>
description = "Production Server"
allow_incremental_backups = enabled

For additional configuration details, there is the BART 2.1 installation guide: Configuring BART 2.1

 

 

At this point, we are ready to run BART:

> /usr/edb/bart/bin/bart -c /usr/edb/bart/etc/bart.cfg BACKUP -s Production
INFO:  creating backup for server 'production'
INFO:  backup identifier: '1525711527592'
63268/63268 kB (100%), 1/1 tablespace

INFO:  backup completed successfully
INFO:  backup checksum: 3499f8f1e05c5bac9abe0a8c8daa04f9 of base.tar
INFO:
BACKUP DETAILS:
BACKUP STATUS: active
BACKUP IDENTIFIER: 1525711527592
BACKUP NAME: none
BACKUP PARENT: none
BACKUP LOCATION: /opt/backups/production/1525711527592
BACKUP SIZE: 61.79 MB
BACKUP FORMAT: tar
BACKUP TIMEZONE: UTC
XLOG METHOD: fetch
BACKUP CHECKSUM(s): 1
 ChkSum                             File
 3499f8f1e05c5bac9abe0a8c8daa04f9   base.tar

TABLESPACE(s): 0
START WAL LOCATION: 000000010000000000000003
BACKUP METHOD: streamed
BACKUP FROM: master
START TIME: 2018-05-07 16:45:27 UTC
STOP TIME: 2018-05-07 16:45:28 UTC
TOTAL DURATION: 1 sec(s)

 

And we should find the backup stored in the backup_path we defined earlier in our bart.cfg file:

> cd opt/backups/production/
> ll
total 8
drwx------ 2 root root 4096 May  7 16:45 1525711527592
drwxr-xr-x 2 root root 4096 May  7 16:09 archived_wals