Home > Database > Mysql Tutorial > Postgresql数据库根据归档日志还原时间点

Postgresql数据库根据归档日志还原时间点

WBOY
Release: 2016-06-07 14:53:55
Original
2177 people have browsed it

Postgresql数据库根据归档日志还原时间点 一、Postgresql数据库根据归档日志还原 www.2cto.com 1、备份运行的data目录 # mv data data_bak 2、解压前天备份的全备到data目录下面 # tar -zxvf fullbackup20121031.tar.gz # mv usr/local/postrgresql-8.4.14/d


Postgresql数据库根据归档日志还原时间点

 

一、Postgresql数据库根据归档日志还原

  www.2cto.com  

1、备份运行的data目录

# mv data data_bak

2、解压前天备份的全备到data目录下面

# tar -zxvf fullbackup20121031.tar.gz

# mv usr/local/postrgresql-8.4.14/data/ /usr/local/postrgresql-8.4.14/

3、清理postmaster.pid 文件

# rm postmaster.pid

4、新建pg_xlog目录和pg_xlog/archive_status(注意权限为postgres)

cd /usr/local/postrgresql-8.4.14/data

 mkdir -p pg_xlog/archive_status

5、复制备份的pg_xlog中的文件到data/pg_xlog目录下

#cp -a data_bak/pg_xlog/0* data/pg_xlog/

6、复制recovery.conf文件到DATA目录下面并指定恢复时间点

#cp /usr/local/postrgresql-8.4.14/share/postgresql/recovery.conf.sample  data/recovery.conf

#修改recovery.conf文件中,

restore_command = 'cp /backup/wals/%f %p' //归档日志目录

recovery_target_time = '2012-10-31 11:41:50 ' //指定归档时间点,如没指定恢复到故障前的最后一完成的事务

 

7、启动数据库

/etc/init.d/postgresql-8.4 start

8、查看数据库日志

# tail -f postgresql-2012-10-31_121721.csv

………..

last completed transaction was at log time 2012-10-31 11:40:12.353374+08" /指定时间点的最后一个提交的事务

archive recovery complete",,,,,,,, //归档日志恢复完成

database system is ready to accept connections  //数据库已经可以连接

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template