溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何實(shí)現(xiàn)pg_basebackup備份恢復(fù)

發(fā)布時(shí)間:2022-01-10 17:50:01 來(lái)源:億速云 閱讀:261 作者:柒染 欄目:數(shù)據(jù)庫(kù)

這篇文章跟大家分析一下“如何實(shí)現(xiàn)pg_basebackup備份恢復(fù)”。內(nèi)容詳細(xì)易懂,對(duì)“如何實(shí)現(xiàn)pg_basebackup備份恢復(fù)”感興趣的朋友可以跟著小編的思路慢慢深入來(lái)閱讀一下,希望閱讀后能夠?qū)Υ蠹矣兴鶐椭?。下面跟著小編一起深入學(xué)習(xí)“如何實(shí)現(xiàn)pg_basebackup備份恢復(fù)”的知識(shí)吧。

創(chuàng)建基礎(chǔ)備份:
pg_basebackup -Ft -Pv -Xf -z -Z5 -p 5432 -D /pgdata/10/backup/

1.移除故障的數(shù)據(jù)目錄或者新建數(shù)據(jù)目錄:
2.創(chuàng)建數(shù)據(jù)目錄并且解壓使用pg_basebackup創(chuàng)建的備份:
mkdir -p /pgdata/10/data1
chmod 0700 /pgdata/10/data1
tar xvzf base.tar.gz -C /pgdata/10/data1/

3.創(chuàng)建recovery.conf文件進(jìn)行配置:
cp /opt/pg10/share/postgresql/recovery.conf.sample /pgdata/10/data1/recovery.conf
chmod 0600 recovery.conf

select current_timestamp;

vi recovery.conf
a.恢復(fù)到最新:
restore_command = 'cp /pgdata/10/archive_wal/%f %p'
recovery_target_timeline = 'latest'

b.恢復(fù)到指定的時(shí)間點(diǎn):
restore_command = 'cp /pgdata/10/archive_wal/%f %p'
recovery_target_time = '2019-04-02 13:16:49.007657+08'

c.創(chuàng)建還原點(diǎn):
SELECT pg_create_restore_point('restore_point1');

d.恢復(fù)到還原點(diǎn):
restore_command = 'cp /pgdata/10/archive_wal/%f %p'
recovery_target_name ='restore_point1'

備注,在做的時(shí)候最好切換一個(gè)日志:select pg_switch_wal();

啟動(dòng)數(shù)據(jù)庫(kù)進(jìn)行恢復(fù):
pg_ctl start -D /pgdata/10/data1/

關(guān)于如何實(shí)現(xiàn)pg_basebackup備份恢復(fù)就分享到這里啦,希望上述內(nèi)容能夠讓大家有所提升。如果想要學(xué)習(xí)更多知識(shí),請(qǐng)大家多多留意小編的更新。謝謝大家關(guān)注一下億速云網(wǎng)站!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI