標籤:pg_probackup postgresql 10
測試環境說明
OS:CentOS Linux release 7.3.1611 (Core) X64
PG:pg10 beta3 source install
pg_probackup: 2.0.3 source install
建立歸檔備份目錄
[[email protected] ~]# mkdir /backupdir
[[email protected] ~]# chown postgres.postgres -R /backupdir
資料庫參數配置
### - Archiving - ###
archive_mode = on
archive_command = ‘pg_probackup archive-push -B /backupdir --instance pg10 --wal-file-path %p --wal-file-name %f‘
### default ###
max_wal_senders = 10
hot_standby = on
full_page_writes = on
初始化備份目錄
[[email protected] ~]# su - postgres
[[email protected] ~]$ pg_probackup init -B /backupdir
INFO: Backup catalog ‘/backupdir‘ successfully inited
添加備份執行個體目錄
[[email protected] ~]$ pg_probackup add-instance -B /backupdir -D /pgdata10/ --instance pg10
INFO: Instance ‘pg10‘ successfully inited
顯示備份執行個體配置
[[email protected] ~]$ pg_probackup show-config -B /backupdir --instance pg10
#Backup instance info
PGDATA = /pgdata10/
system-identifier = 6460633300993501667
#Connection parameters:
PGDATABASE = postgres
#Replica parameters:
#Logging parameters:
#Retention parameters:
#Compression parameters:
compress-algorithm = none
compress-level = 6
[[email protected] ~]$ pg_probackup backup -B /backupdir -b full --instance pg10
INFO: wait for pg_stop_backup()
INFO: Backup OVKYC7 completed
[[email protected] ~]$
增量備份
[[email protected] ~]$ pg_probackup backup -B /backupdir -b PAGE --instance pg10
INFO: wait for LSN 0/4000028 in archived WAL segment /backupdir/wal/pg10/000000010000000000000004
INFO: wait for pg_stop_backup()
INFO: Backup OVKYME completed
[[email protected] ~]$
顯示備份
[[email protected] ~]$ pg_probackup show -B /backupdir
BACKUP INSTANCE ‘pg10‘
===============================================================================================================================
Instance ID Recovery time Mode WAL Current/Parent TLI Time Data Start LSN Stop LSN Status
===============================================================================================================================
pg10 OVKYME 2017-09-01 10:51:56 PAGE ARCHIVE 1 / 0 8s 4407kB 0/4000028 0/50000F0 OK
pg10 OVKYC7 2017-09-01 10:45:57 FULL ARCHIVE 1 / 0 17s 31MB 0/2000060 0/2000198 OK
[[email protected] ~]$
驗證備份
[[email protected] ~]$ pg_probackup validate -B /backupdir --instance pg10
INFO: Validate backups of the instance ‘pg10‘
INFO: Validate backup OVKYME
INFO: backup validation completed successfully
INFO: Validate backup OVKYC7
INFO: backup validation completed successfully
INFO: All backups are valid
[[email protected] ~]$
恢複備份
[[email protected] pgdata10]$ pg_probackup restore -B /backupdir --instance pg10 -D /pgdata10/
INFO: backup validation completed successfully
配置儲存期限
[[email protected] ~]$ pg_probackup set-config -B /backupdir --instance pg10 --retention-redundancy 2 --retention-window 7
[[email protected] ~]$ pg_probackup show-config -B /backupdir --instance pg10
#Backup instance info
PGDATA = /pgdata10/
system-identifier = 6460633300993501667
#Connection parameters:
PGDATABASE = postgres
#Replica parameters:
#Logging parameters:
#Retention parameters:
retention-redundancy = 2
retention-window = 7
#Compression parameters:
compress-algorithm = none
compress-level = 6
[[email protected] ~]$
並行備份
full
[[email protected] ~]$ pg_probackup backup -B /backupdir --instance pg10 -b FULL -j 4
INFO: wait for pg_stop_backup()
INFO: Backup OVL360 completed
[[email protected] ~]$
incremental
[[email protected] ~]$ pg_probackup backup -B /backupdir --instance pg10 -b page -j 6
INFO: wait for LSN 0/B000028 in archived WAL segment /backupdir/wal/pg10/00000002000000000000000B
INFO: wait for pg_stop_backup()
INFO: Backup OVL3BK completed
[[email protected] ~]$
[[email protected] ~]$
[[email protected] ~]$ pg_probackup show -B /backupdir --instance pg10
===============================================================================================================================
Instance ID Recovery time Mode WAL Current/Parent TLI Time Data Start LSN Stop LSN Status
===============================================================================================================================
pg10 OVL3BK 2017-09-01 12:33:24 PAGE ARCHIVE 2 / 1 6s 4417kB 0/B000028 0/C0000F0 OK
pg10 OVL360 2017-09-01 12:30:11 FULL ARCHIVE 2 / 1 13s 31MB 0/9000060 0/9000198 OK
pg10 OVKYME 2017-09-01 10:51:56 PAGE ARCHIVE 1 / 0 8s 4407kB 0/4000028 0/50000F0 OK
pg10 OVKYC7 2017-09-01 10:45:57 FULL ARCHIVE 1 / 0 17s 31MB 0/2000060 0/2000198 OK
[[email protected] ~]$
restore
[[email protected] ~]$ pg_probackup restore -B /backupdir --instance pg10 -D /pgdata10/ -j 6
INFO: backup validation completed successfully
INFO: Restore of backup OVL3BK completed.
[[email protected] ~]$ pg_probackup show -B /backupdir --instance pg10 -D /pgdata10
===============================================================================================================================
Instance ID Recovery time Mode WAL Current/Parent TLI Time Data Start LSN Stop LSN Status
===============================================================================================================================
pg10 OVL3BK 2017-09-01 12:33:24 PAGE ARCHIVE 2 / 1 6s 4417kB 0/B000028 0/C0000F0 OK
pg10 OVL360 2017-09-01 12:30:11 FULL ARCHIVE 2 / 1 13s 31MB 0/9000060 0/9000198 OK
pg10 OVKYME 2017-09-01 10:51:56 PAGE ARCHIVE 1 / 0 8s 4407kB 0/4000028 0/50000F0 OK
pg10 OVKYC7 2017-09-01 10:45:57 FULL ARCHIVE 1 / 0 17s 31MB 0/2000060 0/2000198 OK
[[email protected] ~]$
本文出自 “yiyi” 部落格,請務必保留此出處http://heyiyi.blog.51cto.com/205455/1961899
postgresql 10Database Backup pg_probackup 簡明教程