Summary of the DB2 database backup and recovery commands

Source: Internet
Author: User

The following article mainly introduces the summary of the DB2 database backup and recovery commands. If you are curious about the summary of the DB2 database backup and recovery commands, this article will unveil its mystery. The following is a detailed description of the article.

Database, Command database, command

1. Run --> db2cmd

2. Enter db2cmd in the command line.

Enter the db2 create db database name on d:

Create a database on disk D. Assume that the Directory D: \ DB2 \ NODE0000 \ SQL00006 is generated on disk D.

3. cd \

4. Ensure that the database files to be restored exist in the D: \ db_bak \ directory. Make sure that the directory structure is the db2 System Backup Directory

For example, the directory structure is D: \ db_bak \ GXDB.0 \ DB2 \ NODE0000 \ CATN0000 \

Run the following command,

Db2 restore db [DB2 database backup database name] from D: \ db_bak \ taken at 20070302160117 into [Create Database Name above] redirect

After the command is executed, the system prompts:

--------------------------------------------------------

SQL1277N recovery has detected that one or more tablespace containers are inaccessible, or they have been set

"Memory must be defined ".

The DB20000I restore database command is successfully completed.

--------------------------------------------------------

5. According to the directory structure generated by the database in step 2

 
 
  1. db2 set tablespace containers for 0 using (path "D:\DB2\NODE0000\SQLxxxx\SQLT0000.0") 

To:

 
 
  1. db2 set tablespace containers for 0 using (path "D:\DB2\NODE0000\SQL00006\SQLT0000.0") 

The following two modifications are the same

 
 
  1. db2 set tablespace containers for 1 using (path "D:\DB2\NODE0000\SQL00005\SQLT0001.0")  
  2. db2 set tablespace containers for 2 using (path "D:\DB2\NODE0000\SQL00005\SQLT0002.0") 

In the following statement, change mam311 to the database name. dbf.

 
 
  1. db2 set tablespace containers for 3 using (file "D:\tbs\mam311.DBF" 12500) 

In the following statement, change mam311 to the database name _ Temp. dbf.

 
 
  1. db2 set tablespace containers for 4 using (file "D:\tbs\mam311_Temp.DBF" 12500) 

6,

Db2 restore db DB2 database backup database name continue

For databases in Guangxi:

 
 
  1. db2 restore db gxdb continue 

7. Copy the day-to-day file to the D: \ DB2 \ NODE0000 \ SQL00006 \ SQLOGDIR directory and execute the following statement:

Db2 rollforward db create database name to end of logs and complete

The following is an example:

 
 
  1. db2 create db JMAMGX31 on d: 

Cd \

 
 
  1. db2 restore db gxdb from D:\db_bak\ taken at 20070718115305 into JMAMGX redirect  
  2. db2 set tablespace containers for 0 using (path "D:\DB2\NODE0000\SQL00005\SQLT0000.0")  
  3. db2 set tablespace containers for 1 using (path "D:\DB2\NODE0000\SQL00005\SQLT0001.0")  
  4. db2 set tablespace containers for 2 using (path "D:\DB2\NODE0000\SQL00005\SQLT0002.0")  
  5. db2 set tablespace containers for 3 using (file "D:\tbs\JMAMGX.DBF" 12500)  
  6. db2 set tablespace containers for 4 using (file "D:\tbs\JMAMGX_Temp.DBF" 12500)  
  7. db2 restore db GXDB continue  
  8. db2 rollforward db JMAMGX to end of logs and complete   

The above content is a summary of the DB2 database backup and recovery commands. I hope you will have some gains.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.