RESTORING DB2 BACKUP FROM WINDOWS TO AIX. -STEP BY STEP
Since it is a cross platform migration (Windows to AIX ) -a DB2 backup restore will not work.
By using DB2MOVE AND DB2LOOK we can achieve the same as given below.
I will show you a simple example on how to do it step by step.
*****************************************************************
STEPS AT WINDOWS MACHINE
*****************************************************************
As an example I have taken testdb as the database name
Steps 1. Run the db2look command for testdb database to generate the DDL for the testdb database.
db2look -d testdb -e –l –x -o testdb_create.sql
Step2. Create a directory in which to store the logical backup of the source database testdb.
mkdir backup
Step3. Change to the new directory, and create the logical backup using the db2move utility
cd backup
Step 4. db2move testdb export - here by db2move we are exporting data of this db.
Step 5.Transfer the backup of the database and DDL script from Source to Destination.
Transfer testdb_create.sql in ASCII mode, and all backup*.ixf files in binary mode.
******************************************************************************
STEPS AT AIX OR LINUX BOX
******************************************************************************
Step1.
Split the testdb_create.sql script into two scripts. The first is named testdb_tables.sql, and should contain all alias, table, and view creation commands.
The second script is to be named testdb_ri.sql, and picks up where the first stopped, including check and foreign key constraints and grants. Make sure that both scripts have a CONNECT command at the top, and COMMIT, CONNECT RESET, and TERMINATE commands at the end.
Edit the testdb_tables.sql and ensure that any user tablespaces path are according to the filesystem.
Step 2.Create an empty database
db2 create db testdb
Step3. Run the testdb_tables.sql script to create aliases, tables, and views.
db2 –tvf testdb_tables.sql > testdb_tables.out
Step4. Review testdb_tables.out for errors. An easy method of doing this is to run the following command.
grep SQL0 testdb_tables.out|grep –v SQL0403W|grep –v SQL0598W|more
Step5.
Import the data to the tables (the INSERT option can be used instead of REPLACE, but REPLACE is rerunnable).
db2move testdb load -lo INSERT -l /home/datamove -This is the directory which have all the files collected in first step.
Step6.
Run the testdb_ri.sql script to create referential integrity constraints, etc.
db2 –tvf testdb_ri.sql > testdb_ri.out
Review testdb_ri.out for errors. An easy method of doing this is to run the following command.
grep SQL0 testdb_ri.out|grep –v SQL0403W|grep –v SQL0598W|more
Verify that the source and target databases are identical.
Regarding tables with identity columns check this link first
http://www.ibm.com/developerworks/data/library/techarticle/0205pilaka/0205pilaka2.html
Thanks
Since it is a cross platform migration (Windows to AIX ) -a DB2 backup restore will not work.
By using DB2MOVE AND DB2LOOK we can achieve the same as given below.
I will show you a simple example on how to do it step by step.
*****************************************************************
STEPS AT WINDOWS MACHINE
*****************************************************************
As an example I have taken testdb as the database name
Steps 1. Run the db2look command for testdb database to generate the DDL for the testdb database.
db2look -d testdb -e –l –x -o testdb_create.sql
Step2. Create a directory in which to store the logical backup of the source database testdb.
mkdir backup
Step3. Change to the new directory, and create the logical backup using the db2move utility
cd backup
Step 4. db2move testdb export - here by db2move we are exporting data of this db.
Step 5.Transfer the backup of the database and DDL script from Source to Destination.
Transfer testdb_create.sql in ASCII mode, and all backup*.ixf files in binary mode.
******************************************************************************
STEPS AT AIX OR LINUX BOX
******************************************************************************
Step1.
Split the testdb_create.sql script into two scripts. The first is named testdb_tables.sql, and should contain all alias, table, and view creation commands.
The second script is to be named testdb_ri.sql, and picks up where the first stopped, including check and foreign key constraints and grants. Make sure that both scripts have a CONNECT command at the top, and COMMIT, CONNECT RESET, and TERMINATE commands at the end.
Edit the testdb_tables.sql and ensure that any user tablespaces path are according to the filesystem.
Step 2.Create an empty database
db2 create db testdb
Step3. Run the testdb_tables.sql script to create aliases, tables, and views.
db2 –tvf testdb_tables.sql > testdb_tables.out
Step4. Review testdb_tables.out for errors. An easy method of doing this is to run the following command.
grep SQL0 testdb_tables.out|grep –v SQL0403W|grep –v SQL0598W|more
Step5.
Import the data to the tables (the INSERT option can be used instead of REPLACE, but REPLACE is rerunnable).
db2move testdb load -lo INSERT -l /home/datamove -This is the directory which have all the files collected in first step.
Step6.
Run the testdb_ri.sql script to create referential integrity constraints, etc.
db2 –tvf testdb_ri.sql > testdb_ri.out
Review testdb_ri.out for errors. An easy method of doing this is to run the following command.
grep SQL0 testdb_ri.out|grep –v SQL0403W|grep –v SQL0598W|more
Verify that the source and target databases are identical.
Regarding tables with identity columns check this link first
http://www.ibm.com/developerworks/data/library/techarticle/0205pilaka/0205pilaka2.html
Thanks
No comments:
Post a Comment