pg基于时间点的恢复(PITR)

本文介绍了如何在PostgreSQL 9.6中进行基于时间点的恢复(PITR)。首先展示了数据库的wal_level设置为replica,archive_mode开启,并配置了archive_command。接着,通过普通用户和超级用户的操作,创建了一个名为'test'的表并插入数据,进行了pg_start_backup和pg_stop_backup操作,并将WAL日志归档。然后停止数据库,恢复到特定时间点(2017-02-08 17:30:00+08),通过修改recovery.conf配置文件,启动数据库,最终成功恢复到指定状态,此时表'test'中仅包含初始插入的数据。
摘要由CSDN通过智能技术生成
[postgres9.6@db ~]$ psql postgres postgres9.6
Null display is "NULL".
Pager is always used.
Timing is on.
psql (9.6.1)
Type "help" for help.

postgres9.6@[local]:5432 postgres# show wal_level;
 wal_level 
-----------
 replica
(1 row)

Time: 0.270 ms
postgres9.6@[local]:5432 postgres# show archive_mode;
 archive_mode 
--------------
 on
(1 row)

Time: 0.214 ms
postgres9.6@[local]:5432 postgres# show archive_command ;
                                            archive_command                                             
--------------------------------------------------------------------------------------------------------
 DATE=`date +%Y%m%d`;DIR="/home/postgres9.6/arch/$DATE";(test -d $DIR || mkdir -p $DIR)&& cp %p $DIR/%f
(1 row)


Time: 0.188 ms


postgres9.6@[local]:5432 postgres# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit
(1 row)


Time: 2.709 ms


postgres9.6@[local]:5432 p
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值