Summary of DB2 database backup and recovery commands

Source: Internet
Author: User

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, directory structure: D:/db_bak/gxdb.0/DB2/node0000/catn0000/
Run the following command,
DB2 restore DB [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
DB2 set tablespace containers for 0 using (path "D:/DB2/node0000/sqlxxxx/sqlt0000.0 ")
To:
DB2 set tablespace containers for 0 using (path "D:/DB2/node0000/sql00006/sqlt0000.0 ")
The following two modifications are the same
DB2 set tablespace containers for 1 using (path "D:/DB2/node0000/sql00005/sqlt0001.0 ")
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.
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.
DB2 set tablespace containers for 4 using (File "D:/tbs/mam311_temp.dbf" 12500)
6,
DB2 restore DB Backup database name continue
For databases in Guangxi:
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:
DB2 create dB jmamgx31 on D:

CD/

DB2 restore dB gxdb from D:/db_bak/taken at 20070718115305 into jmamgx redirect

DB2 set tablespace containers for 0 using (path "D:/DB2/node0000/sql00005/sqlt0000.0 ")
DB2 set tablespace containers for 1 using (path "D:/DB2/node0000/sql00005/sqlt0001.0 ")
DB2 set tablespace containers for 2 using (path "D:/DB2/node0000/sql00005/sqlt0002.0 ")
DB2 set tablespace containers for 3 using (File "D:/tbs/jmamgx. DBF" 12500)
DB2 set tablespace containers for 4 using (File "D:/tbs/jmamgx_temp.dbf" 12500)

DB2 restore dB gxdb continue

DB2 rollforward dB jmamgx to end of logs and complete
 

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.