Protecting PostgreSQL using pg_basebackup with IBM Spectrum Protect

Protecting PostgreSQL using pg_basebackup with IBM Spectrum Protect

There are many different methods that one can use for protecting PostgreSQL. This time we are going to introduce you to the pg_probackup utility.

  1. Install the IBM Spectrum Protect Client API

# rpm -ivh gsk*.rpm

# rpm –ivh *api*.rpm

# dpkg -i gsk*.deb

# dpkg –i *api*.deb

2. Install the SPFS software

# rpm -ivh spfs*.rpm

# rpm –ivh spictera*.rpm

# dpkg -i spfs*.deb

# dpkg –i spictera*.deb

3. Configure the Spectrum Protect client

# vi /opt/Tivoli/tsm/client/api/bin64/dsm.sys

SERVERNAME spfs

TCPSERVERADDRESS tsm.backupserver.com

ERRORLOGNAME /var/log/dsmerror_spfs.log

4. Register the node on the backup server

TSM> REGISTER NODE SPFS secret DOMAIN=SPFS

 5. Configure the SPFS file system

5.1 Create option file

# echo SERVERNAME spfs > /etc/spfs/dsm.opt

5.2 set initial password

# setpassword /etc/spfs/TSM.PWD <<< secret

5.3 Create spfs configuration

# vi /etc/spfs/spfs.opt

MOUNTPOINT /backup

NODENAME spfs

NODEPWDFILE /etc/spfs/TSM.PWD

OPTIONFILE /etc/spfs/dsm.optMOUNTPOINT /archive

NODENAME spfs

NODEPWDFILE /etc/spfs/TSM.PWD

OPTIONFILE /etc/spfs/dsm.opt

DATATYPE archive

6. mounting the SPFS file system

# mkdir /backup

# mkdir /archive

# mount.spfs /backup

# mount.spfs /archive

You are now ready to start using Spectrum Protect as a file system, storing and retrieving backup data of PostgreSQL

set wal_level to archive or higher, archive_mode to on, and set up an archive_command that performs archiving.

archive_command = cp %p /archive/%f’

$ pg_basebackup -h mydbserver -D /backup/latest_backup \

 — checkpoint=fast -Xf \

 — format=tar

$ pg_ctl -D $PGDATA stop -mf

Restore data from backup

$  tar xzf /backup/latest_backup/base.tar.gz -C /pgdata

# recovery.conf file always exists in the Data Directory of Slave

recovery_target_time = ‘2021–10–23 10:27:34 EDT’

restore_command = ‘cp /archive/%p %f’

recovery_target_action = ‘pause’

recovery_target_inclusive = ‘false’

Start up the PostgreSQL server instance, so that an automatic recovery can be initiated

 

All Posts
×

Almost done…

We just sent you an email. Please click the link in the email to confirm your subscription!

OKSubscriptions powered by Strikingly