user485903
user485903

Reputation: 17

copying db2 database from one instance to other

I have one database under instance db2inst4 and I want to copy that db to another instance, db2inst1. I made a backup with the following command

db2 backup db TDB online

Backup successfull. The timestamp for this backup image is : 20200109121153

after this I tried to restore the bck into the db2inst1

db2 restore database TDB from /appsdata/db2inst4/ taken at 20200109121153 dbpath on /appsdata/db2inst1

DB20000I The RESTORE DATABASE command completed successfully

The restore was successful apparently. But when I check in the db2inst1 to see if the TDB database is there, i get the following

[db2inst1@xxx~]$ ./db2 list db directory

SQL1057W The system database directory is empty. SQLSTATE=01606

i don't know what am I missing

Upvotes: 0

Views: 648

Answers (1)

Kelly Rodger
Kelly Rodger

Reputation: 31

Were you definitely using db2inst1 at the time the RESTORE cmd was issued, either with echo $DB2INSTANCE or the get instance command?

Otherwise the restore utility could have checked the environment of your current instance, determined that your TDB DB already exists there, and restored it as you asked.

Also, just changing the dbpath is not necessarily sufficient as you may also need to redirect the tablespace containers, and there can be other considerations. For instance, see:

https://www.ibm.com/support/pages/how-retore-database-between-different-instance-avoid-authorization-issue-new-instance-user

Upvotes: 2

Related Questions