#备份数据库
db2 backup db TESTDB online to /opt/backup/db2_backup/$(date "+%Y%m%d")/TESTDB/ include logs
#查看备份日志路径
db2 list history backup all for TESTDB
#将备份文件及日志传到备份服务器
scp -r /opt/sisc/db2_data_new/TESTDB/ root@10.254.192.158:/opt/sisc/db2_data_new/TESTDB/
备份的服务器操作
#断开数据库连接
db2 force application all
#删除数据库
db2 drop db TESTDB
#恢复数据库路径需要和备份数据库路径相同
db2 create database TESTDB on /opt/sisc/test/testdb
#恢复操作
db2 restore database TESTDB from 备份路径 taken at 20180315190154
#查看日志路径
db2 get db cfg for TESTDB | grep " Path to log files"
#把备份日志拷贝到数据库日志目录下
cp S0001148.LOG /opt/sisc/test/testdb/db2inst1/NODE0000/SQL00001/SQLOGDIR
#恢复日志
db2 rollforward db TESTDB to end of logs and stop