Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2006
    Location
    Bangalore
    Posts
    57

    Red face Unanswered: 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 04:53.

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    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.
    Last edited by singhipst; 07-07-06 at 08:45.
    Ritesh Kumar Singh
    IBM Certified DB2 DBA for LUW
    **Knowledge Is Theft If Not Shared !!**

  4. #4
    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

  5. #5
    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 !!**

  6. #6
    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

  7. #7
    Join Date
    Dec 2011
    Posts
    2
    this post may solve your question

    http://www.dbforums.com/db2/1657998-...ml#post6527787


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •