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
- 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 DB2 database 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
The above content is a summary of the DB2 database backup and recovery commands. I hope you will have some gains.