DEV Community

Eduardo Issao Ito
Eduardo Issao Ito

Posted on

DB2 backup/restore schema

Creating the backup

Exporting DDL from EXAMPLE schema:

db2look -d MYDB -z EXAMPLE -e -o EXAMPLE.sql
Enter fullscreen mode Exit fullscreen mode

Exporting data from schema:

db2move MYDB export -sn EXAMPLE
Enter fullscreen mode Exit fullscreen mode

The db2move command will create a lot of files, incluing db2move.lst.

It contains internal tables like EXPLAIN_* and ADVISE_*. If you don't need them just delete de corresponding lines from db2move.lst.

Restoring backup

Creating objects:

db2 -t -f EXAMPLE.sql
Enter fullscreen mode Exit fullscreen mode

Restoring data:

db2move MYDB import

db2move MYDB import -io insert_update
Enter fullscreen mode Exit fullscreen mode

Top comments (0)