postgresql 10Database Backup pg_probackup 簡明教程

來源:互聯網
上載者:User

標籤: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 簡明教程

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.