[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
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中进行基于时间点的恢复(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'中仅包含初始插入的数据。
最低0.47元/天 解锁文章
1294

被折叠的 条评论
为什么被折叠?



