简单的数据库备份/还原+gzip压缩/解压

db2 force applications all

db2 backup db sdzy [to /home]

nohup db2 backup db dcdb to /bak1118 with 1 buffers buffer 256 compress &

压缩:gzip SDZY.NODE~.001.gz
解压:gzip -d SDZY.NODE~.001.gz

db2 restore db sdzy (taken at 20100101030004)
数据库名称不一样的时候,各种数据库文件目录不相同,所以这种方法不行。

db2 list db directory


恢复数据库后,连接数据库时,出现错误如下:
SQL1117N  A connection to or activation of database "ZJCRM" cannot be made 
because of ROLL-FORWARD PENDING.  SQLSTATE=57019
解决方案:
执行命令:
db2 "rollforward db zjcrm to end of logs and stop noretrieve"
错误提示:
SQL4970N  Roll-forward recovery on database "ZJCRM" cannot reach the specified 
stop point (end-of-log or point-in-time) because of missing or corrupted log 
file(s) on database partition(s) "0". Roll-forward recovery processing has 
halted on log file " S0010139.LOG".
使用命令db2 get db cfg for zjcrm得到数据库的日志路径:
 Path to log files                                       = /home/db2inst1/db2inst1/NODE0000/SQL00005/SQLOGDIR/
 Overflow log path                     (OVERFLOWLOGPATH) = 
 Mirror log path                         (MIRRORLOGPATH) = 
 First active log file                                   = S0010139.LOG
找到原文件 S0010139.LOG 复制到日志路径行,
重新执行命令
db2 "rollforward db zjcrm to end of logs and stop noretrieve"
成功。

你可能感兴趣的:(简单的数据库备份/还原+gzip压缩/解压)