The following articles mainly describe the correct steps for DB2 backup and cross-platform migration. If you are curious about the correct steps for DB2 backup and cross-platform migration, the following articles will unveil its secrets. The following is a detailed description of the article. I hope you can learn from it.
Database, backup, DB2, cross-platform migration, migration
First, set the archive parameters.
Java code
- 1. db2 update db cfg for using implements logpath/home/db2inst1/mirror_log // mirror log
- 2. db2 get db cfg for // check whether it is successful
- 3. db2 update db cfg for using userexit on // Enable User exit
- 4. db2 update db cfg for using logretain on // enable archiving logs
- 5. db2 update db cfg for using trackmod on // enable the Incremental backup function
- 6. db2stop force
- 7. db2start
- 8. db2 backup db to/home/db2inst1/off_back //
- Db2 update db cfg for using implements logpath/home/db2inst1/mirror_log // mirror log
- Db2 get db cfg for // check whether the operation is successful
- Db2 update db cfg for using userexit on // Enable User exit
- Db2 update db cfg for using logretain on // enable archiving logs
- Db2 update db cfg for using trackmod on // enable the Incremental backup function
- Db2stop force
- Db2start
- Db2 backup db to/home/db2inst1/off_back //
DB2 Online Database Backup
Java code
- 1. db2 backup db online to/home/db2inst1/on_back // online backup
- 2. db2 backup db online incremental to/home/db2inst1/on_back // online incremental backup
- 3. db2 list history backup all for // view backup records
- 4. db2 get db cfg for // view the location of the log and cp to a secure directory for rollforward.
- 5. db2stop force; db2start; db2 drop db // manually drop the database to simulate disaster recovery
- Db2 backup db online to/home/db2inst1/on_back // online backup
- Db2 backup db online incremental to/home/db2inst1/on_back // perform incremental backup online
- Db2 list history backup all for // view backup records
- Db2 get db cfg for // view the location of the log, cp to a secure directory for rollforward use.
- Db2stop force; db2start; db2 drop db // manually drop the database to simulate disaster recovery
Restore online database
Db2 code
- 1. db2ckrst-d-t 20070608032820-r database // The help tool prompts recovery.
- 2. db2 restore db incremental from/home/db2inst1/on_back taken at 20070608032820 // restore the data file
- 3. Restore the full backup first, and then restore the Incremental backup. You cannot automatically find the full backup file.
- 4. db2 rollforward database to end of logs and complete overflow log path '(/home/db2inst1/log)' // The rollback log does not agree with the following: "recover full backup first, and then restore the Incremental Backup"
- 5. For incremental recovery, your practice is reversed. If you do this, you will receive the SQL2574N error message.
- 6. The order of recovery has been clearly indicated in db2ckrst.
- 7. The following are the steps to test the log backup and recovery in the backup image:
- 8. Note:/home/db2inst1/on_back/# indicates the location of the backup file.
- 9./home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# Is the Database log location, which is obtained through db2 get db cfg.
- 10. db2stop force; db2start; db2 drop db # simulate a disaster and drop the database.
- 11. db2 backup db online to/home/db2inst1/on_back/include logs # Back up image files with logs
- 12. db2 backup db online incremental to/home/db2inst1/on_back/include logs # Back up incremental image files with logs
- 13. db2 RESTORE db incremental automatic FROM/home/db2inst1/on_back/taken at 20070612070526 LOGTARGET/Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# restore Data images and log files with timestamps of 20070612070526
- 14. db2 rollforward database to end of logs and complete // roll back log
- 15. The database has been dropped in "10". How do I perform online backup in "20?
- 16. Note:/home/db2inst1/on_back/# indicates the location of the backup file.
- 17./home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# Is the Database log location, which is obtained through db2 get db cfg.
- 18. db2 backup db online to/home/db2inst1/on_back/include logs # Back up image files with logs
- 19. db2 backup db online incremental to/home/db2inst1/on_back/include logs # Back up incremental image files with logs
- 20. db2stop force; db2start; db2 drop db # simulate a disaster and drop the database.
- 21. db2 RESTORE db incremental automatic FROM/home/db2inst1/on_back/taken at 20070612070526 LOGTARGET/Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# restore Data images and log files with timestamps of 20070612070526
- 22. db2 rollforward database to end of logs and complete // roll back log
- Db2ckrst-d-t 20070608032820-r database // The help tool prompts recovery.
- Db2 restore db incremental from/home/db2inst1/on_back taken at 20070608032820 // restore the data file
- Recover the full backup first, and then restore the Incremental backup. You cannot automatically find the full backup file.
- Db2 rollforward database to end of logs and complete overflow log path '(/home/db2inst1/log)' // The rollback log does not agree with the following: "recover full backup first, and then restore the Incremental Backup"
- For incremental recovery, your practice is reversed. If you do this, you will receive the SQL2574N error message.
- In db2ckrst, we have clearly indicated the order of recovery.
- The following are the steps to test the backup and recovery of logs in the backup image:
- Note:/home/db2inst1/on_back/# indicates the location of the backup file.
- /Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# Is the Database log location, which is obtained through db2 get db cfg.
- Db2stop force; db2start; db2 drop db # simulate a disaster and drop the database.
- Db2 backup db online to/home/db2inst1/on_back/include logs # Back up image files with logs
- Db2 backup db online incremental to/home/db2inst1/on_back/include logs # Back up incremental image files with logs
- Db2 RESTORE db incremental automatic FROM/home/db2inst1/on_back/taken at 20070612070526 LOGTARGET/Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# restore Data images and log files with timestamps of 20070612070526
- Db2 rollforward database to end of logs and complete // roll back log
- The database has been dropped in "10". How do I perform online backup in "20?
- Note:/home/db2inst1/on_back/# indicates the location of the backup file.
- /Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# Is the Database log location, which is obtained through db2 get db cfg.
- Db2 backup db online to/home/db2inst1/on_back/include logs # Back up image files with logs
- Db2 backup db online incremental to/home/db2inst1/on_back/include logs # Back up incremental image files with logs
- Db2stop force; db2start; db2 drop db # simulate a disaster and drop the database.
- Db2 RESTORE db incremental automatic FROM/home/db2inst1/on_back/taken at 20070612070526 LOGTARGET/Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# restore Data images and log files with timestamps of 20070612070526
- Db2 rollforward database to end of logs and complete // roll back log
The above is the DB2 backup method
The following describes how to migrate DB2 data across platforms.
Source database AIX platform + DB2 target platform LINUX
First, export the warehouse structure from the source database.
Db2 code
- 1. db2look -d dbname -e -o db2look.sql
- db2look -d dbname -e -o db2look.sql
Then export the source database DB2 data
Db2 code
- 1. db2move dbname export –u user –p password
- db2move dbname export –u user –p password
Db2move. lst records all exported files and can be edited to determine which data tables to import.
Then, create a new DB2 database on the target linux host, import the structure and data,
Db2 code
- 1. db2 -tvf db2look.sql
- 2. db2move dbname import
The above content is an introduction to DB2 backup and cross-platform migration. I hope you will have some gains.