Backup and Restore DB2 to Another Machine

By Unknown Saturday, October 17, 2015

Use db2look to export DDL and db2move to export data.

The name of the database is "mydb" as an example
On source machine:
$ mkdir migrate
$ cd migrate
$ db2look -d mydb -e -a -o db2look.sql
$ db2move mydb export
$ cd ..
$ tar cf migrate.tar migrate
$ gzip migrate.tar

Transfer migrate.tar.gz to destination machine.
Note: Make sure that the database is created.
If not create it with the following:
Create database [db name, eg:mydb]

On destination machine:
$ gunzip migrate.tar.gz
$ tar xf migrate.tar
$ cd migrate
$ db2 -tvf db2look.sql
$ db2move mydb load

You may encounter -668 error when your application runs on the restored database. You can fix that with SET INTEGRITY.

If you have cyclic dependencies of the tables when you are trying to do SET INTEGRITY, the solution is at this post "Solving cyclic dependency for DB2 SET INTEGRITY".


No Comment to " Backup and Restore DB2 to Another Machine "