EnterpriseDB recently launched a new tool for backup and recovery – named simply EDB Backup and Recovery Tool, or BART. This tool makes the DBA’s life easier by simplifying the tasks for managing their Postgres physical backup and recovery tasks, whether they are PostgreSQL or Postgres Plus Advanced Server deployments.
BART has the following advantages over custom scripts for managing backups:
1. It’s stable and it uses the tool pg_basebackup to take a physical backup. This tool has been well defined and is well-supported by the PostgreSQL community.
2. It catalogs all of the backups users are taking, which is important in terms of:
i. Listing the type of backups used
ii. Listing the status of those backups with server information.
3. BART also provides functionality to restore backups, with all required archived WAL files. So automation around this tool will make DBAs’ lives easier for restore and recovery.
4. BART provides an option to validate your backup by using checksum. This is useful for confirming you took a valid backup and it is not corrupted at disk level.
5. BART provides an option to define your retention policy around the backups you are keeping.
Given all of the above advantages, I decided to give this new tool a try and share some tips. To get started, you need the following prerequisites:
1. BART currently requires a Linux 64 bit platform, CentOS 6.x or RHEL 6.x
2. Need to have password-less, direct SSH access to the target machine where you want to restore backups as well as the database servers you want backed up
3. Install the Postgres Plus Advanced Server or PostgreSQL binaries for pg_basebackup
Yum or rpm
To install this tool, you have two options that I will explore below:
1. Yum command 2. Rpm command.
Using the yum command:
To perform a yum command installation, BART users can ask EDB for credentials to the EnterpriseDB yum repository and configure the their local yum repository as follows:
echo "[tools] name=EnterpriseDB Tools baseurl=http://username:email@example.com/tools/redhat/rhel-$releasever-$basearch enabled=1 gpgcheck=0" > /etc/yum.repos.d/edbtools.repo
After creating the yum repo, the user can execute the following command to install BART:
yum install edb-bart
If the user doesn’t want to install the EDB Backup and Recovery Tool using the yum command, then the user can download a free standing rpm using the link below from EDB’s website:
and then enter the rpm install command as follows:
rpm -ivh edb-bart-1.0.1-1.rhel6.x86_64.rpm
After installing BART using the above commands, the user can see the binaries in the directory:/usr/edb-bart-1.0/bin and a sample BART configuration file in /usr/edb-bart-1.0/etc
That’s a very easy installation.
For more information on configuring BART Host and Database Host, the following document will help:
pg_basebackup configuration for PostgreSQL:
After the installation of the BART binaries, the user also has to create a BART configuration file.
The following is a sample configuration file for BART:
[BART] bart-host= firstname.lastname@example.org backup_path = /opt/backup pg_basebackup_path = /usr/ppas-9.4/bin/pg_basebackup logfile = /tmp/bart.log [PG] host = 127.0.0.1 port = 5432 user = postgres description = "Postgres server" [PPAS94] host = 127.0.0.1 port = 5444 user = enterprisedb description = "PPAS 94 server"
Global Configuration Settings
Content under the [BART] tag are called global configuration settings. Under this tag are the following:
1. bart-host: the IP address of the host on which BART is installed. The value for this parameter must be specified in the form: bart_user@bart_host_address, where bart_user is the operating system user account on the BART host that is used to run BART and owns the BART backup catalog directory. bart_host_address is the IP address of the BART host.
2. backup_path: specifies the file system parent directory where all BART database server base backups and archived WAL files are stored. This parameter is required.
3. pg_basebackup_path: specifies the path to the pg_basebackup program of the Postgres database server installed on the BART host.
4. log file: specifies the path to the BART log file. This parameter is optional. If no path to a log file is specified after logfile =, or if the parameter is commented out, BART does not create a log file.
The remaining part of configuration file is self-explanatory. The TAG: [PG]/[PPAS94] part is content for servers which the user wants to back up.
After performing the above configuration on the Backup Server, the user has to do set following settings on the servers that they want to back up. Below are the settings for enabling backup using pg_basebackup.
The user has to set a few parameters in PostgreSQL postgresql.conf file, which he wants to backup:
1. wal_level parameter to archive or hot_standby. 2. archive_mode=on 3. archive_command setting. 4. max_wal_senders to 1 or more than one, since pg_basebackup uses the replication protocol to copy data directory.
For more information on each setting please refer to the following:
2. archive_mode and archive_command:
With the above settings, the user then needs to update the pg_hba.conf file for the replication connection.
Note: The above settings are for pg_basebackup to take backups using replication protocols. In case users need more information about pg_basebackup and settings, please use the above mentioned link
How BART Works
Now, since we have configured both servers, let’s have a look how BART works.
The following command executes a backup:
bart -c bart.cfg BACKUP -s ppas94
And below is the output:
[bart@localhost ~]$ bart -c bart.cfg BACKUP -s ppas94 INFO: creating backup for server 'ppas94' INFO: backup identifier: '1413852137762' 6394456/6394456 kB (100%), 1/1 tablespace INFO: backup checksum: 7f49ea9653511308710c174f22ec765d INFO: backup completed successfully [bart@localhost ~]$
That was an easy way to take a backup. The DBA can also create a job to execute the above command to take backups.
If the user wants to list the backup using BART, the user can use the option SHOW-BACKUPS:
[bart@localhost ~]$ bart -c bart.cfg SHOW-BACKUPS -s ppas94 Server Name Backup ID Backup Time Backup Size ppas94 1413852137762 2014-10-20 17:43:41 6244.59 MB
This is useful for knowing what backups a user has available for recovery. The above command gives important information:
1. Backup ID: It’s a unique ID for the physical backup 2. Backup Time: Time when backup was taken 3. Backup Size: Size of backup
This information is useful when a user wants to plan for recovery using backup. This way, the user can also plan for disk size.
Sometimes a user wants to verify their backup state. VERIFY-CHKSUM option is useful in this case:
[bart@localhost ~]$ bart -c bart.cfg VERIFY-CHKSUM -s ppas94 -i 1413852137762 Server Name Backup ID Verify ppas94 1413852137762 OK
I have to say, after putting EDB BART through its paces, I think DBAs will enjoy having such a great tool for making Backup Management easy.
In my next post, I will blog about the Recovery process.
Filed under: Postgres Plus Advanced Server, PostgreSQL Tagged: BACKUP AND RECOVERY, DBA, edb, EnterpriseDB, Postgres Plus, PostgreSQL, PPAS