Exporting and importing the database schema

You can export the IBM® Product Master schema to a .tar file by using the db2_export.sh script.

Before you begin

Before you run the db2_export.sh script in the $TOP/src/db/scripts/backup directory, you must:
  • Shut down the Product Master application that is connected to the database schema.
  • Ensure that the backup directory exists on the local disks on the database server and does not contain DB2® data files.
  • Ensure that the owner of the backup directory is the Db2 instance owner on the database server.
  • Ensure that you log in to the database server as the Db2 instance owner to copy and run the db2_export.sh script.
    Important: You must not run the script from the application server.
  • If you copy db2_export.sh script from a Windows-based computer to the database server, ensure that the script is saved in the UNIX format. If the file is not in the UNIX format, the system might introduce end-of-line characters that cause the script to fail.

About this task

Running the db2_export.sh script generates the SQL scripts that are required to create tables, indexes, and sequences with their current values, and stores them in a .tar file in the backup directory. The .tar file is useful for maintaining a backup of your database schema and for creating a similar environment on another computer. You can also upload this file when you need to send a copy of your database schema to IBM Support for resolution of any issue.

Procedure

Run the db2_export.sh shell script that is in the $TOP/src/db/scripts/backup folder.
For example, to export the wpcdb database schema to the /u01/backup directory in a file that is called july10bkp, you can specify the following command:
db2_export.sh --db=wpcdb --dbuser=wpc1 --dbpassword=passwd --backupdir=/u01/backup --bkpfile=july10bkp

What to do next

You can use the db2_fast_import.sh script to import the IBM Product Master schema from the .tar file that is created by running the db2_export.sh script. Importing the schema is useful for restoring a backup of your database schema and for creating a similar environment on another computer. Before you run the db2_fast_import.sh script, you must:
  • Ensure that there are no errors at the time of export. If there are any errors, you must rectify the errors, run the db2_export.sh script again, and then try the import.
  • Ensure that there is enough space in the table spaces before you import the database schema. You can use the db2 list tablespaces show detail command to check the available space in the table spaces. If required, you can add more space.
  • Ensure that the db2_fast_import.sh script is saved in the UNIX format if you copy it from a Windows-based computer to the database server. If it is not in the UNIX format, the system might introduce end-of-line characters that cause the script to fail.
  • Run this script only when you log in as the Db2 database administrator.
  • Optional: Create a new empty database user if you want to import to a new database user.
CAUTION:
If you import into an existing schema with tables, all existing tables are dropped and data is lost.
You can import the schema into the same or a different database under the same schema name or a different schema name.
  1. Run the db2_fast_import.sh shell script that is in the $TOP/src/db/scripts/backup folder.
    For example, to import the trigodev database schema from the /u01/backup/july10/july10bkp directory to the pimdb database, you can specify the following command:
    db2_fast_import.sh --db=pimdb --dbuser=trigodev --dbpassword=trigodev --backupdir=/u01/backup/july10/july10bkp