If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to Clone Database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-06, 03:49
singhipst singhipst is offline
Registered User
 
Join Date: Jul 2006
Location: Bangalore
Posts: 57
Red face How to Clone Database

Hi All,

I am using DB2 v8.2 ESE on Windows server 2003.

I have a database its name is 'abc' now. I have taken full backup of this data base now i want to create new database by using this backup image with the diffrennt name link 'xyz'.

How can i do it????

Or i alrady have one database i want to create one more same database with diffrent name for that what i have to do?????

Regards:
Ritesh Kumar

Last edited by singhipst; 07-07-06 at 03:53.
Reply With Quote
  #2 (permalink)  
Old 07-07-06, 04:53
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You can restore the database backup to a different database name. However, you will need to use the redirected restore method, since you need to place the tablespace containers in a different location than the database that still exists on that server.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 07-07-06, 07:29
singhipst singhipst is offline
Registered User
 
Join Date: Jul 2006
Location: Bangalore
Posts: 57
Thanks for your valuable reply

I tried this command on DB2 CLP

My databese name is 'RIT22' and i want to create same database with name 'TEST1'.

db2 restore db test1 from <path>

But it is showing following error message

SQL2542N No match for a database image file was found based on the source
database alias "TEST1" and timestamp "" provided.
__________________
Ritesh Kumar Singh
IBM Certified DB2 DBA for LUW
**Knowledge Is Theft If Not Shared !!**

Last edited by singhipst; 07-07-06 at 07:45.
Reply With Quote
  #4 (permalink)  
Old 07-07-06, 17:14
sharrisdb2 sharrisdb2 is offline
Registered User
 
Join Date: Jul 2005
Location: Irvine, CA
Posts: 23
You'll need to use a redirect restore method as Marcus_A said.

Example (assumed you are using a full offline backup)

1st - create a new blank database in either the same instance or a new one. It can even be on another machine. Just make sure you have access to the backup file wherever your new database resides. I suggest making a blank database because you can set the configs to low levels if needed. Many times you may be making a copy of production that allocates huge bufferpools, other mem pools, and huge logs. You may be moving this copy to another system that cannot handle the settings. I find it better to restore over an existing blank db with mild configurations first and then tune the new db if necessary. A redirected restore will not change the dbconfig settings.

2nd - run the redirect commands

db2 restore database <source database name> from <path> taken at <timestamp> into <target database> resplace existing redirect without rolling forward;

-- NOTE: at this point the database has been partially restored, but the tablespace containers need to be set. Make sure you know what you are doing here. You need to assign each tablespace a new set of containers so the new database has a place to store data. DO NOT use the same paths/file names as the source database. This is a very simple example. It does not include possible DMS tablespaces, nor multiple containers per tablespace.

db2 "set tablespace containers for 0 using (path 'db2/01/catlog')"
db2 "set tablespace containers for 1 using (path 'db2/01/temp')"
db2 "set tablespace containers for 2 using (path 'db2/01/userspace')"

db2 restore database <source database> continue

_______________________________________________

Again, this is a very simple example. It will not work if you try to use an online backup, or if you have more tablespaces than just the basic ones. Also, beware if you have created new bufferpools. The blank database you restore over must have all bufferpools defined in the source database. THe allocations can be different, but they have to exist.

For instance, let's say you had created new tablespaces "BIG_DMS_DATA" and "BIG_DMS_INDEX" and also created two new bufferpools "DMSDATABP and DMSINDEXBP on the source database. You need to make sure that the new blank target database also has the two new bufferpools. You don;t need to create the tablespaces inthe new database though. THe restore will do that for you, but you do need to add set container commands in the restore to address the tablespaces.

Example:

db2 restore .... redirect....
db2 "set tablespace containers for 0 using (path 'db2/01/catlog')"
db2 "set tablespace containers for 1 using (path 'db2/01/temp')"
db2 "set tablespace containers for 2 using (path 'db2/01/userspace')"
db2 "set tablespace containers for 3 using (file 'db2/01/dmsdata1' 524288, file 'db2/02/dmsdata2' 524288)"
db2 "set tablespace containers for 4 using (file 'db2/01/dmsindex1' 262144, file 'db2/02/dmsindex2' 262144)"
db2 restore database <source database> continue


This example shows 2 dms tbspaces with 2 containers each.

Hope this helps.

-- Steve
Certified DB2 LUW DBA
Reply With Quote
  #5 (permalink)  
Old 07-10-06, 08:51
singhipst singhipst is offline
Registered User
 
Join Date: Jul 2006
Location: Bangalore
Posts: 57
Thanks sharrisdb2,

Its working now i am able to do the same
__________________
Ritesh Kumar Singh
IBM Certified DB2 DBA for LUW
**Knowledge Is Theft If Not Shared !!**
Reply With Quote
  #6 (permalink)  
Old 07-13-06, 22:58
anksagr anksagr is offline
Registered User
 
Join Date: Jul 2005
Posts: 102
Hi Steve,

I was looking at all the posts for some help on redirected restore and I found your post. You have really explained the process really well.

But I have a question if I want to use an online backup image and I have copied all the logs and the backup image from tsm to the server where my target database is residing. I am not sure how to do the redirected restore using an online backup image.

Would really appreciate your help!

Thanks
Anks
Reply With Quote
  #7 (permalink)  
Old 12-01-11, 04:01
phyllis518liu phyllis518liu is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
this post may solve your question

Clone database with a different name

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On