Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize pg_basebackup backup and recovery

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article analyzes "how to achieve pg_basebackup backup and recovery". The content is detailed and easy to understand. Friends who are interested in "how to achieve pg_basebackup backup and recovery" can follow the editor's idea to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's learn more about "how to achieve pg_basebackup backup and recovery" with the editor.

Create a basic backup:

Pg_basebackup-Ft-Pv-Xf-z-Z5-p 5432-D / pgdata/10/backup/

1. Remove the faulty data directory or create a new data directory:

two。 Create a data directory and extract the backup created with pg_basebackup:

Mkdir-p / pgdata/10/data1

Chmod 0700 / pgdata/10/data1

Tar xvzf base.tar.gz-C / pgdata/10/data1/

3. Create a recovery.conf file for configuration:

Cp / opt/pg10/share/postgresql/recovery.conf.sample / pgdata/10/data1/recovery.conf

Chmod 0600 recovery.conf

Select current_timestamp

Vi recovery.conf

a. Restore to the latest:

Restore_command ='cp / pgdata/10/archive_wal/%f% p'

Recovery_target_timeline = 'latest'

b. Restore to the specified point in time:

Restore_command ='cp / pgdata/10/archive_wal/%f% p'

Recovery_target_time = '2019-04-02 13 13 Fran 49.007657 08'

c. Create a restore point:

SELECT pg_create_restore_point ('restore_point1')

d. Restore to the restore point:

Restore_command ='cp / pgdata/10/archive_wal/%f% p'

Recovery_target_name = 'restore_point1'

Note: when doing this, you'd better switch a log: select pg_switch_wal ()

Start the database for recovery:

Pg_ctl start-D / pgdata/10/data1/

On how to achieve pg_basebackup backup and restore to share here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report