PostgreSQL Base Backup & Restore
How to Setup Base Backup
go to data directorystep1:
pg_hba.confipv4 and repliaction entery
vi pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 192.168.1.221/32 trust
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 192.168.1.222/32 trust
step2:
vi postgresql.conflistern_address=*
archive_mode=on
archive_command='cp %p /arch/%f'
wal_level=replica
full_page_writes=on
max_wal_sender=6
wal_keep_segement=500
max_replication_slot=2
log_statement='all'
STEP3: restart the server
su - postgres
cd /usr/pgsql-11/bin
./pg_ctl -D /var/lib/pgsql/11/data restart
step4: run pg_basebackup utility tool
pg_basebackup Options:
-h hostname
-p port number
-P progres
-v verbose
-c checkpoint
-X wals
-R create recovery.conf file
-T tablespace
-T curent_tablespace_directory=backup_tablespace_directory
without tablespace:
./pg_basebackup -h 192.168.1.21 -p 5432 -P -v -X stream or fetch -c fast -R -Fp -D /backup/bk_1
with tablespace
./pg_basebackup -h 192.168.1.221 -p 5432 -P -v -c fast -X stream -R -T /tbs_1=/tbs_new1 -T /tbs_2=/tbs_new2mn -Fp -D /backup/bk_`date +%d%m%y%H%M%S`
Restore:
su - postgres/usr/pgsql-11/bin/pg_ctl -D /bk_1 start
Comments
Post a Comment