Transfer, copy or move DB2 database from Linux to Windows
Sometimes you may encounter a situation where you have to deploy a database created on one platform to another platform. For example, you may have a DB2 database on Linux, but now you have to get it working on Windows. Lets assume that you already have DB2 installed on that other machine, and it is of same version number as the original one.
If this other machine were Linux, you could simply make a backup and then restore it on this other machine. However, since it is Windows, you cannot do that. You have to export the database, in order to get it working. It is actually very simple, when you know it.
Original machine
Open a shell as DB2 instance owner. Make a directory and cd into there. Then run two commands
mkdir my_export
cd my_export
db2move YOUR_DB_NAME export
db2look -d YOUR_DB_NAME -e -a -o db2look.sql
db2move prepares tables for export, and last command creates a script. You will notice that my_export directory contains several .ixf, .msg and possibly .lob files. It also contains file EXPORT.out, db2look.sql and db2move.lst. Now you should transfer all these files into your target machine.
Target machine
Create a suitable working directory and copy all files mentioned above in there. Then run following commands in that directory
db2 create db YOUR_DB_NAME
db2 -tvf db2look.sql
db2move YOUR_DB_NAME load
It is possible that some tables produce errors about integrity check pending. You can correct this with
db2 set integrity for TABLENAME immediate checked
Now your database should work.
Comments
One Response to “Transfer, copy or move DB2 database from Linux to Windows”Trackbacks
Check out what others are saying...[...] today I found this jewel that explains all of what needs to be done in just a few lines. Thanks so much, TeknoMagus, you’ve helped me a lot! I knew it must be not only feasible, but [...]