Showing results for 
Search instead for 
Did you mean: 

Bart 1.1 Quickstart

EDB Team Member


Quickly (less than five minutes) install EPAS 9.5 and BART on RHEL 6/7, and configure backups to be run every minute but only retaining three backups (and associated WAL files)



Running instance of RHEL 6/7



There are several components to this quickstart

  1. EPAS Installation (/usr/ppas-9.5) with two clusters (cluster1 and cluster2) in /var/lib/ppas/9.5

  2. BART Installation (/usr/edb-bart-1.1)

  3. BART Backup Directory (/backups)

  4. CRON Jobs for regularly performing backups

BART 1_1 Screen Shot 2016-08-16 at 11.07.44 PM.png


Steps (as root user)




# Set YUM username/password for use later in the script

export YUM_USER=<yum user>

export YUM_PASSWORD=<yum password>


# Setup YUM repository for installing EPAS as the PEM

# repository

rpm -Uvh

# Set real YUM usernames and passwords in EDB Repo

sed -i "s/<username>:<password>/$YUM_USER:$YUM_PASSWORD/g" /etc/yum.repos.d/edb.repo

# Enable the EPAS 9.5 repo and the EDB Tools repoo in edb.repo
sed -i "\/ppas95/,/gpgcheck/ s/enabled=0/enabled=1/" /etc/yum.repos.d/edb.repo


# Install EPAS 9.5

yum -y install ppas95-server

# Create and start cluster 1 with default port 5444, executed as enterprisedb

su - enterprisedb -c "mkdir /var/lib/ppas/9.5/cluster1"

su - enterprisedb -c "chmod 700 /var/lib/ppas/9.5/cluster1"

su - enterprisedb -c "/usr/ppas-9.5/bin/initdb -D /var/lib/ppas/9.5/cluster1"

su - enterprisedb -c "/usr/ppas-9.5/bin/pg_ctl -D /var/lib/ppas/9.5/cluster1 start"   


# Create and start cluster 2 with non-default port 5445, executed as enterprisedb

su - enterprisedb -c "mkdir /var/lib/ppas/9.5/cluster2"

su - enterprisedb -c "chmod 700 /var/lib/ppas/9.5/cluster2"

su - enterprisedb -c "/usr/ppas-9.5/bin/initdb -D /var/lib/ppas/9.5/cluster2"

su - enterprisedb -c "sed -i 's/#port = 5444/port = 5445/' /var/lib/ppas/9.5/cluster2/postgresql.conf"

su - enterprisedb -c "/usr/ppas-9.5/bin/pg_ctl -D /var/lib/ppas/9.5/cluster2 start"   


# Note your two running Postgres clusters

ps -ef | grep edb-postgres


# Enable the EnterpriseDB tools repo in edb.repo
sed -i "\/enterprisedb-tools/,/gpgcheck/ s/enabled=0/enabled=1/" /etc/yum.repos.d/edb.repo


# Install BART 1.1

yum -y install edb-bart


# Create our backup directory

mkdir /backup

chown enterprisedb:enterprisedb /backup


# Copy off the sample BART config file

mv -f /usr/edb-bart-1.1/etc/bart.cfg /usr/edb-bart-1.1/etc/bart.cfg_sample


# Create our BART config file for backing up our two clusters

touch /usr/edb-bart-1.1/etc/bart.cfg

chown enterprisedb:enterprisedb /usr/edb-bart-1.1/etc/bart.cfg

echo "[BART]" > /usr/edb-bart-1.1/etc/bart.cfg echo "bart-host= enterprisedb@" >> /usr/edb-bart-1.1/etc/bart.cfg echo "backup_path = /backup" >> /usr/edb-bart-1.1/etc/bart.cfg echo "pg_basebackup_path = /usr/ppas-9.5/bin/pg_basebackup" >> /usr/edb-bart-1.1/etc/bart.cfg echo "wal_compression = enabled" >> /usr/edb-bart-1.1/etc/bart.cfg echo "logfile = /backup/bart.log" >> /usr/edb-bart-1.1/etc/bart.cfg echo "" >> /usr/edb-bart-1.1/etc/bart.cfg echo "[cluster1_backup]" >> /usr/edb-bart-1.1/etc/bart.cfg echo "host =" >> /usr/edb-bart-1.1/etc/bart.cfg echo "port = 5444" >> /usr/edb-bart-1.1/etc/bart.cfg echo "user = enterprisedb" >> /usr/edb-bart-1.1/etc/bart.cfg echo "retention_policy = 3 BACKUPS" >> /usr/edb-bart-1.1/etc/bart.cfg echo "description = \"Cluster 1\"" >> /usr/edb-bart-1.1/etc/bart.cfg echo "" >> /usr/edb-bart-1.1/etc/bart.cfg echo "[cluster2_backup]" >> /usr/edb-bart-1.1/etc/bart.cfg echo "host =" >> /usr/edb-bart-1.1/etc/bart.cfg echo "port = 5445" >> /usr/edb-bart-1.1/etc/bart.cfg echo "user = enterprisedb" >> /usr/edb-bart-1.1/etc/bart.cfg echo "retention_policy = 4 BACKUPS" >> /usr/edb-bart-1.1/etc/bart.cfg echo "description = \"Cluster 2\"" >> /usr/edb-bart-1.1/etc/bart.cfg


# Initialize BART and check that backup folders were created

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart INIT"

find /backup -name "*"


# Configure both clusters to allow enterprisedb to connect to the replication psudo-database

# by uncommenting the "host replication" lines

sed -i "s/#host[ ]*replication/host   replication/g" /var/lib/ppas/9.5/cluster*/pg_hba.conf


# Configure wal settings so that BART can do a pg_basebackup

sed -i "s/#wal_level = minimal/wal_level = archive/" /var/lib/ppas/9.5/cluster*/postgresql.conf

sed -i "s/#max_wal_senders = 0/max_wal_senders=3/" /var/lib/ppas/9.5/cluster*/postgresql.conf


# Configure achiving to the /backup folder (see BART docs for using passwordless scp for databases on remote hosts)

sed -i "s/#archive_mode = off/archive_mode = on/" /var/lib/ppas/9.5/cluster*/postgresql.conf

sed -i "s,#archive_command = '',archive_command = 'cp %p /backup/cluster1_backup/archived_wals/%f'," /var/lib/ppas/9.5/cluster1/postgresql.conf

sed -i "s,#archive_command = '',archive_command = 'cp %p /backup/cluster2_backup/archived_wals/%f'," /var/lib/ppas/9.5/cluster2/postgresql.conf


# Restart clusters for configuration changes to take effect, done as enterprisedb

su - enterprisedb -c "/usr/ppas-9.5/bin/pg_ctl -w -D /var/lib/ppas/9.5/cluster1 restart"

su - enterprisedb -c "/usr/ppas-9.5/bin/pg_ctl -w -D /var/lib/ppas/9.5/cluster2 restart"


# Test a compressed backup of all servers, and do it four times
# so that we will have some backups to be marked as obsolete

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart BACKUP -z -s all"

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart BACKUP -z -s all"

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart BACKUP -z -s all"

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart BACKUP -z -s all"


# Test managing the backups (mark as obsolete and compress WALs)
# Any backups (and associated WAL archive files) past the retention
# period that we specified in bart.cfg above should be marked
# as obsolete.

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart MANAGE -s all"


# Test deleting any backups/WALs marked as obsolete)

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart MANAGE -s all -d"


# Now backup, manage, and delete obsoletes in a single command

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart BACKUP -z -s all && /usr/edb-bart-1.1/bin/bart MANAGE -s all && /usr/edb-bart-1.1/bin/bart MANAGE -s all -d"


# Show your current backup server settings

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart SHOW-SERVERS"


# Show your current backups

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart SHOW-BACKUPS"


# Do a simple restore (see docs for using passwordless SCP to restore to a remote server)

mkdir /var/lib/ppas/9.5/cluster1_restore

chmod 700 /var/lib/ppas/9.5/cluster1_restore

chown enterprisedb:enterprisedb /var/lib/ppas/9.5/cluster1_restore

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart RESTORE -s cluster1_backup -p /var/lib/ppas/9.5/cluster1_restore"


# Change the restored cluster's port and start it

su - enterprisedb -c "sed -i 's/#port = 5444/port = 5446/' /var/lib/ppas/9.5/cluster1_restore/postgresql.conf"

su - enterprisedb -c "/usr/ppas-9.5/bin/pg_ctl -w -D /var/lib/ppas/9.5/cluster1_restore start" 

ps -ef | grep edb-postgres


# Setup the backups to be done via a cron job every minute (just to make it easy to watch in this quickstart)

export BACKUP_SCHEDULE="* * * * *"

export BACKUP_COMMAND="/usr/edb-bart-1.1/bin/bart BACKUP -z -s all && /usr/edb-bart-1.1/bin/bart MANAGE -s all && /usr/edb-bart-1.1/bin/bart MANAGE -s all -d"

su - enterprisedb -c "(echo \"$BACKUP_SCHEDULE $BACKUP_COMMAND\") | crontab -"

su - enterprisedb -c "crontab -l"


# Show the backups every minute or so to verify that backups are occurring

su - enterprisedb -c "/usr/edb-bart-1.1/bin/bart SHOW-BACKUPS"


# Congratulations!  You have setup two Postgres clusters to be backed up on a schedule with a 

# specified retention policy, as well as having tested the restore process.



  • Full BART documentation is here:

  • If the BART host is different than the Postgres host, then the Postgres host will need to do passwordless scp of the archive logs to the BART host, and the BART host will need to do passwordless scp to restore a cluster to a remove Postgres host. This is covered in detail in the documentation linked above.

  • This example uses "trust" in pg_hba.conf for BART to connect to the Postgres clusters to do backups. In a production environment, you would want to use md5 passwords or client certificates and then configure the BART user to have the .pgpass file or client certificates necessary to connect to the Postgres clusters.

  • This example does all backups at the same frequency. It is entirely possible that a production environment would backup some servers daily, some weekly, and maybe some monthly. When specifying "bart BACKUP", you can specify "-s <server>" to backup a specific cluster. You might have one cron job for nightly backups and a separate cron job for weekly or monthly backups.

  • On a BART restore, at the bottom of the restored cluster's postgresql.conf file, archiving is disabled. This is to prevent a practice restore from unintentionally overwriting production archive logs. If you want the restored cluster to continue archiving, remove the bottom line from the restored postgresql.conf.



This guide is intended to get you up and started with a default installation of BART as quickly as possible. Please consult the documentation listed above for more exhaustive coverage of the features of BART.

1 Comment
A best quick guide.