db2 数据备份和还原
connect to odsdb user reportdb using reportdb
connect to rspdb1 user rspdb using rspdb1
connect to rspdb user rsp using rsp
db2 connect to cognosdb user db2admin using db2admin
connect to wasdb user db2admin using db2admin
db2 backup database cognosdb user db2admin using db2admin to e:\db2\backup
db2 catalog tcpip node rspdb remote 192.188.1.153 server 50003
db2 catalog database rspdb as rspdb at node rspdb
db2 catalog tcpip node rspdb1 remote 192.188.1.242 server 50002
db2 catalog database rspdb as rspdb1 at node rspdb1
db2 conncet to rspdb user rsp using rsp 生产
db2 conncet to rspdb1 user rspdb using rspdb1 测试
db2 conncet to cognosdb user db2admin using db2admin 本地
db2 catalog tcpip node rspdb2 remote localhost server 50001
db2 catalog database cognosdb as cognosdb at node rspdb2
db2 catalog tcpip node rspdb3 remote localhost server 50001
db2 catalog database wasdb as wasdb at node rspdb3
db2 list db directory
数据迁移方法
export脚本示例 db2 connect to testdb user test password test
db2 "export to aa1.ixf of ixf select * from table1"
db2 "export to aa2.ixf of ixf select * from table2"
db2 connect reset
import脚本示例 db2 connect to testdb user test password test
db2 "load from aa1.ixf of ixf replace into table1 COPY NO without prompting "
db2 "load from aa2.ixf of ixf replace into table2 COPY NO without prompting "
db2 connect reset
export脚本示例 db2 connect to rspdb user rsp using rsp
db2 "export to aa1.ixf of ixf select * from APP_HELP_INFO"
db2 "export to aa2.ixf of ixf select * from table2"
db2 connect reset
import脚本示例 db2 connect to cognosdb user db2admin using db2admin
db2 "load from aa1.ixf of ixf replace into APP_HELP_INFO COPY NO without prompting"
db2 "load from aa2.ixf of ixf replace into table2 COPY NO without prompting "
db2 connect reset
export to c:/aa.ixf select * from sys_app_info
export to 'C:\sys_app_info.del' of del select * from sys_app_info
import from c:/aa.ixf
import from 'C:\sys_app_info.del' of del insert into sys_app_info;
db2look -d cognosdb -e -o ddlfile -i db2admin -w db2admin
db2move cognosdb export -u db2admin -p db2admin
db2 connect to odsdb user reportdb using reportdb
db2 backup database odsdb user reportdb using reportdb to e:\db2\backup
db2 connect to wasdb user db2admin using db2admin
db2 backup database wasdb user db2admin using db2admin to e:\db2\backup
直接使用db2 backup db的命令,就可以完成你的需求,
如果系统出现问题,需要创建INSTANCE用户,再创建INSTANCE,再恢复DB
整个库的信息就全部恢复回来了。
db2 restore db bqry from d:\backup into btst