首页 | Linux 基础 | 资讯动态 | Linux 应用 | Linux 服务器 | Linux 开发 | Linux 安全 | 专题 | 联盟论坛
  当前位置:主页>Linux 服务器>数据库应用>文章内容
PostgreSQL的热备和恢复
来源:www.chinaunix.net 作者:Seamus Dean 发布时间:2007-06-22  

###################################
&do_backup();

####################################
# tell psql end backup
####################################
&end_backup();

####################################
# mail the user about the result
####################################
&mail_user("PostgreSQL backup successfully.");

到这里,备份脚本基本上就完了,你可以将hotBackup.pl放在crontab中周期性的执行。

就算/home/pgsql/database目录彻底崩溃,我们可以像下面这样迅速恢复到1分钟内的数据:
#cp /disk3/PostgreSQL/base/base.tar ./
#tar xvf base.tar
#cd database/
#vi recovery.conf
输入如下内容:
restore_command='cp /disk3/PostgreSQL/archives/%f "%p"'
然后将/home/pgsql/database/pg_xlog/下面的WAL清空。
启动PostgreSQL,我们可以看到如下的LOG信息:
LOG: could not create IPv6 socket: Address family not supported by protocol
LOG: database system was interrupted at 2005-04-11 23:13:28 PDT
LOG: starting archive recovery
LOG: restore_command = "cp /disk3/PostgreSQL/archives/%f "%p""
cp: cannot stat `/disk3/PostgreSQL/archives/00000001.history': No such file or directory
LOG: restored log file "00000001000000000000002E.008EFCAC.backup" from archive
LOG: restored log file "00000001000000000000002E" from archive
LOG: checkpoint record is at 0/2E8EFCAC
LOG: redo record is at 0/2E8EFCAC; undo record is at 0/0; shutdown FALSE
LOG: next transaction ID: 5271; next OID: 6351357
LOG: automatic recovery in progress
LOG: redo starts at 0/2E8EFCE8
LOG: restored log file "00000001000000000000002F" from archive
LOG: restored log file "000000010000000000000030" from archive
LOG: restored log file "000000010000000000000031" from archive
LOG: restored log file "000000010000000000000032" from archive
LOG: restored log file "000000010000000000000033" from archive
LOG: restored log file "000000010000000000000034" from archive
LOG: restored log file "000000010000000000000035" from archive
LOG: restored log file "000000010000000000000036" from archive
LOG: restored log file "000000010000000000000037" from archive
LOG: restored log file "000000010000000000000038" from archive
LOG: restored log file "000000010000000000000039" from archive
LOG: restored log file "00000001000000000000003A" from archive
LOG: restored log file "00000001000000000000003B" from archive
LOG: restored log file "00000001000000000000003C" from archive
LOG: restored log file "00000001000000000000003D" from archive
LOG: restored log file "00000001000000000000003E" from archive
LOG: restored log file "00000001000000000000003F" from archive
LOG: restored log file "000000010000000000000040" from archive
LOG: restored log file "000000010000000000000041" from archive
LOG: restored log file "000000010000000000000042" from archive
LOG: restored log file "000000010000000000000043" from archive
LOG: restored log file "000000010000000000000044" from archive
LOG: restored log file "000000010000000000000045" from archive
LOG: restored log file "000000010000000000000046" from archive
LOG: restored log file "000000010000000000000047" from archive
LOG: restored log file "000000010000000000000048" from archive
LOG: restored log file "000000010000000000000049" from archive
LOG: restored log file "00000001000000000000004A" from archive
LOG: restored log file "00000001000000000000004B" from archive
LOG: restored log file "00000001000000000000004C" from archive
LOG: record with zero length at 0/4C2BABE4
LOG: redo done at 0/4C2BABA8
LOG: restored log file "00000001000000000000004C" from archive
LOG: archive recovery complete
LOG: database system is ready


显示数据已经成功恢复。
/home/pgsql/database/下面的recovery.conf会变为:recovery.done.

结论:
PostgreSQL8的PITR已经做得非常的成功,完全有可能替代Oracle,Sqlserver
而成为企业的首选。所以,我们玩PostgreSQL的兄弟们,一定要对它有信心!


共2页: 上一页 [1] 2 下一页
 
如果您对本文有任何疑问或者建议,请到论坛讨论区发表您的意见: >> 论坛入口
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
  热点文章
·在Linux x86上安装Oracle数据库1
·Linux系统下的Oracle数据库编程
·Linux下免费数据库PostgreSQL开
·如何在你的Linux机器上安装运行O
·Oracle开发应用
·Heartbeat_2.0.3配置MySQL5.0.18
·编制一个Mysql数据库自动备份脚
·mysql 优化参数(十项)详解设置
·MySQL数据库系统的常规管理介绍
·新手入门--全面介绍MySQL的基础
·让PHP网站运转如飞 MySQL 的优化
·Linux系统下Mini SQL数据库开发
  相关文章
·源码安装Postgresql8.1.3+PostGI
·Linux下免费数据库PostgreSQL开
·Linux系统下的Oracle数据库编程
·Linux系统下Mini SQL数据库开发
·MySQL数据库系统的常规管理介绍
·MYSQL高效率地装载数据解决方案
·编制一个Mysql数据库自动备份脚
·Heartbeat_2.0.3配置MySQL5.0.18
·MySQL的数据类型和建库策略
·mysql 优化参数(十项)详解设置
·Oracle开发应用
·在UnixWare7.1.1上安装Oracle8i

本站信息源至:互联网络,均为学习,交流所用,如有版权问题,请联系我们.
站长QQ:397422079 E_mail:riechelr_hl@unix5.com
转载本站内容请注明原作者名.谢谢!