DB2数据库备份,冷备份、热备份、增量备份实验
mkdir archivelog
mkdir backup
2.造库,用那个模板库
db2star
3.造表,
db2 connect to sample
db2 "create table test (id int,name varchar(20),password varchar(20))"
db2 "insert into test values (1,'cto','51')"
4.改数据库参数
启用归档日志
db2 update db cfg for sample using LOGARCHMETH1 disk:/home/db2inst1/archivelog
启用增量备份
db2 update db cfg for sample using trackmod on
改完参数以后数据库处于挂起状态,需要备份一次数据库
db2 backup db ken to /home/db2inst1/backup
查看配置
db2 get db cfg for sample | grep -i log
5.接着造数据
db2 connect to sample
db2 "insert into test values (2,'51','cto')"
6.删库,不跑路
db2 drop db sample
7.恢复
db2 restore db sample from /home/db2inst1/backup taken at 20181012094410
8.前滚
db2 rollforward db sample to end of logs and complete overflow log path '(/home/db2inst1/archivelog)'
9.查看数据是否正常.
db2 "select * from test"
热备
db2 "backup db sample online to /home/db2inst1/backup"
增量备
db2 "backup db sample online incremental to /home/db2inst1/backup"
测试方式同上.
网站栏目:DB2数据库备份,冷备份、热备份、增量备份实验
网站地址:http://hbruida.cn/article/ipeshi.html