This section describes how to create an archive to protect your database against system failure using the BACKUP function.
Database backup files must be referenced in the DB2 Server for VSE & VM history area, so that if you use Data Restore to restore the database, all changes in successive log files are automatically reapplied when the STARTUP=U parameter is specified.
Before you start to backup your database, you must stop your application server.
You must stop your server by issuing an SQLEND UARCHIVE operator command to have the backup referenced in the history area as shown in Figure 62. After all logical units of work are completed, the database manager indicates that you must save the directory and all dbextents. If the database is running in LOGMODE=L and the log is not empty, a log archive is taken before terminating the database.
When the server is stopped, take the user archive using Data Restore.
Figure 62. Stopping the Server with SQLEND UARCHIVE
ARI0062A ENTER A DB2 FOR VSE OPERATOR COMMAND.
SQLEND UARCHIVE
ARI0028I THE DATABASE MANAGER IS TERMINATING.
ARI0065I OPERATOR COMMAND PROCESSING IS COMPLETE.
ARI0239I EXTERNAL LABELING OF THIS ARCHIVE IS
TYPE DATABASE ARCHIVE
TIMESTAMP 09-09-95 14:30:15
ARI0205I YOU MUST USER-ARCHIVE THE DIRECTORY AND 8
DBEXTENTS(S) BUT NOT THE LOG
ARI0032I THE DATABASE MANAGER HAS TERMINATED.
You can only recover from the archive. You cannot reapply the changes referenced in the log.
In this case, it is not necessary for the server to know when the database backup was done. You can use the SQLEND operator command to stop the server, as shown in Figure 63. If you want to ensure that the log history is updated, use the SQLEND UARCHIVE command.
Figure 63. Stopping the Server with SQLEND
ARI0062A ENTER A DB2 FOR VSE OPERATOR COMMAND.
SQLEND
ARI0028I THE DATABASE MANAGER IS TERMINATING.
ARI0065I OPERATOR COMMAND PROCESSING IS COMPLETED.
ARI0032I THE DATABASE MANAGER HAS TERMINATED.
To process a backup of a database, you must create a SYSIN file to identify the database you want to process and the name of the function to process. (Figure 64 contains an overview of the BACKUP process.)
Figure 64. Overview of Backing Up a Database
In Figure 64, the DB2 Server for VSE & VM DATABASE disk represents the directory and all the defined dbextents. You can create the backup file on tape or DASD. You can also take dual backups to tape, DASD, or a combination of tape and DASD. When the backup is complete, Data Restore produces a report specifying how many blocks have been saved from the directory, how many blocks have been saved from all the saved dbextents, and a list of all the tables that can be reloaded from the file.
To back up your database, use the BACKUP command. For a incremental backup of your database, use the INCREMENTAL BACKUP command. See BACKUP for more information on this command.
Step 2.1 explains how to back up your database in a VM environment. To process the BACKUP function in a VSE environment, go to Step 2.2 Backing Up Your Database (VSE).
Figure 65. Contents of SYSIN File (BACKUP SYSIN A)
OPTIONS CONFIRM=NO
CONTROL DBNAME=dbname
BACKUP
Figure 66. Executing a BACKUP to Tape in a VM Environment.
/**/
(1) ---> 'FILEDEF ARCHIV TAP1 SL 1 (RECFM VB BLOCK 32760'
(2) ---> 'FILEDEF SYSPRINT DISK BACKUP SYSPRINT A'
(3) ---> 'FILEDEF SYSIN DISK BACKUP SYSIN A'
(4) ---> 'XTS91001'
You must be able able to access the dbname SQLFDEF files that are on the database production disk when you are executing the Data Restore functions. Make sure you link and access the minidisk where Data Restore is installed before executing the BACKUP function.
If the CONFIRM=YES parameter is specified, you must confirm that you want to continue with the backup before starting the BACKUP function.
Note: | In all the other Data Restore functions, you edit the SYSIN file and modify the parameters before execution. For the BACKUP function, the procedure avoids operator intervention and does not require you to edit the file. |
If you want to take a dual backup, execute an EXEC like the one shown in Figure 67 instead of the one shown in Figure 66.
Figure 67. Executing a Dual Backup in a VM Environment
Figure 68. Control Statement to Execute a Backup in a VM Environment
OPTIONS DEVICE2=DASD CONFIRM=NO
CONTROL DBNAME=dbname
BACKUP
You must be able able to access the dbname SQLFDEF files that are on the database production disk when you are executing the Data Restore functions. Make sure you link and access the minidisk where Data Restore is installed before executing the BACKUP function.
To take a dual backup, assign a second device as DEVICE2=DASD. Figure 67 is an example of writing one backup to tape and the other to DASD.
Note: | To write dual backups to tape, assign both devices to tape. To write dual backups to DASD, assign both devices to DASD. |
If the CONFIRM=YES parameter is specified, you must confirm that you want to continue with the backup before executing the backup process.
To process FULL backup, modify the SYSIN in Figure 66 specifying BACKUP FULL instead of BACKUP on the last statement.
To process incremental backup, modify the SYSIN in Figure 66 specifying BACKUP INCREMENTAL instead of BACKUP on the last statement.
Figure 69. SYSPRINT File After Executing A BACKUP
(1) ---> XTS9-143 OPTIONS DEVICE2=DASD CONFIRM=NO
(1) ---> XTS9-143 CONTROL DBNAME=dbname
(1) ---> XTS9-143 BACKUP
XTS9-100 Data Restore feature VERSION 7.1.0
XTS9-309 Processing DB2 Version 7 Release 1
(2) ---> XTS9-172 DB2 was ended with LOGMODE L
(3) ---> XTS9-141 External labeling of this archive is
XTS9-142 Base dbname date 17/10/95 - time 12:12:49
XTS9-001 Processing directory
XTS9-002 20010 Directory blocks saved
(4) ---> XTS9-013 Table SQLDBA.COST_TABLE may be reloaded
XTS9-013 Table SQLDBA.DEPARTMENT may be reloaded
XTS9-013 Table SQLDBA.EMPLOYEE may be reloaded
XTS9-013 Table SQLDBA.EMPLOYEE_ACTIVITY may be reloaded
XTS9-013 Table SQLDBA.FOREIG may be reloaded
XTS9-013 Table SQLDBA.INVENTORY may be reloaded
XTS9-013 Table SQLDBA.OPERATIONS may be reloaded
XTS9-013 Table SQLDBA.ORDERS may be reloaded
XTS9-013 Table SQLDBA.PLAN_TABLE may be reloaded
XTS9-013 Table SQLDBA.ROUTINE may be reloaded
XTS9-145 Table SQLDBA.STORED QUERIES may be reloaded
XTS9-013 Table SQLDBA.STRUCTURE_TABLE may be reloaded
XTS9-013 Table SQLDBA.SUPPLIERS may be reloaded
XTS9-013 Table SQLDBA.SYSLANGUAGE may be reloaded
XTS9-013 Table SQLDBA.SYSTEXT1 may be reloaded
XTS9-013 Table SQLDBA.SYSTEXT2 may be reloaded
XTS9-013 Table SQLDBA.SYSUSERLIST may be reloaded
(5) ---> XTS9-006 processing DDSK1
(5) ---> XTS9-005 2 blocks saved
(5) ---> XTS9-006 processing DDSK4
(5) ---> XTS9-005 1 blocks saved
(6) ---> XTS9-006 processing DDSK1
(7) ---> XTS9-005 2870 blocks saved
XTS9-006 processing DDSK2
XTS9-005 383 blocks saved
XTS9-006 processing DDSK3
XTS9-005 7 blocks saved
XTS9-006 processing DDSK4
XTS9-005 1 blocks saved
XTS9-006 processing DDSK5
XTS9-005 1 blocks saved
XTS9-006 processing DDSK6
XTS9-005 1 blocks saved
XTS9-006 processing DDSK7
XTS9-005 1 blocks saved
XTS9-006 processing DDSK8
XTS9-005 1 blocks saved
XTS9-007 processing successfully completed
Figure 70. JCL to Execute a BACKUP to Tape in a VSE Environment
// JOB BACKUP
(1) ---> // LIBDEF *,SEARCH=(PRD2.DB2vrm,PRD2.RCVvrm)
(2) ---> // EXEC PROC=ARIS71DB
(3) ---> // TLBL ARCHIV,'ARCHIVE.DB2'
(4) ---> // ASSGN SYS006,180
(5) ---> // MTC REW,SYS006
(6) ---> // EXEC XTS91001,SIZE=AUTO
(7) ---> OPTIONS DEVICE=TAPE
(8) ---> CONTROL DBNAME=dbname
(9) ---> BACKUP
/*
The SYSLST report contains a list of all the executed processes. A function report produced by the BACKUP function is described in Figure 72.
If you want to take a dual backup, execute a BACKUP job using JCL similar to that shown in Figure 71 instead of that shown in Figure 70.
Figure 71. Executing a Dual Backup in a VSE Environment
The SYSLST report contains a list of all the processes executed. A function report produced by the BACKUP function is described in Figure 72.
Figure 72. Report after a Backup is Completed
(1) ---> XTS9-143 OPTIONS DEVICE=TAPE CONFIRM=NO
(1) ---> XTS9-143 CONTROL DBNAME=dbname
(1) ---> XTS9-143 BACKUP
XTS9-143 /*
XTS9-100 Data Restore feature VERSION 7.1.0
XTS9-309 Processing DB2 Version 7 Release 1
(2) ---> XTS9-172 DB2 was ended with LOGMODE L
(3) ---> XTS9-141 External labeling of this archive is
XTS9-142 Base SQL/VSE date 17/10/95 - time 12:12:49
XTS9-001 Processing directory
XTS9-002 20010 Directory blocks saved
(4) ---> XTS9-013 Table SQLDBA.COST_TABLE may be reloaded
XTS9-013 Table SQLDBA.DEPARTMENT may be reloaded
XTS9-013 Table SQLDBA.EMPLOYEE may be reloaded
XTS9-013 Table SQLDBA.EMPLOYEE_ACTIVITY may be reloaded
XTS9-013 Table SQLDBA.FOREIG may be reloaded
XTS9-013 Table SQLDBA.INVENTORY may be reloaded
XTS9-013 Table SQLDBA.OPERATIONS may be reloaded
XTS9-013 Table SQLDBA.ORDERS may be reloaded
XTS9-013 Table SQLDBA.PLAN_TABLE may be reloaded
XTS9-013 Table SQLDBA.ROUTINE may be reloaded
XTS9-145 Table SQLDBA.STORED QUERIES may be reloaded
XTS9-013 Table SQLDBA.STRUCTURE_TABLE may be reloaded
XTS9-013 Table SQLDBA.SUPPLIERS may be reloaded
XTS9-013 Table SQLDBA.SYSLANGUAGE may be reloaded
XTS9-013 Table SQLDBA.SYSTEXT1 may be reloaded
XTS9-013 Table SQLDBA.SYSTEXT2 may be reloaded
XTS9-013 Table SQLDBA.SYSUSERLIST may be reloaded
(5) ---> XTS9-006 processing DDSK1
(5) ---> XTS9-005 1 blocks saved
(5) ---> XTS9-006 processing DDSK4
(5) ---> XTS9-005 1 blocks saved
(6) ---> XTS9-006 processing DDSK1
(7) ---> XTS9-005 2870 blocks saved
XTS9-006 processing DDSK2
XTS9-005 383 blocks saved
XTS9-006 processing DDSK3
XTS9-005 7 blocks saved
XTS9-006 processing DDSK4
XTS9-005 1 blocks saved
XTS9-006 processing DDSK5
XTS9-005 1 blocks saved
XTS9-006 processing DDSK6
XTS9-005 1 blocks saved
XTS9-006 processing DDSK7
XTS9-005 1 blocks saved
XTS9-006 processing DDSK8
XTS9-005 1 blocks saved
XTS9-007 processing successfully completed
If you used the SQLEND UARCHIVE command to stop the application server, the next time you start the server, you are asked if the BACKUP process executed successfully as shown in Figure 73.
Figure 73. Restarting the Database After BACKUP When the Process Was Successful
ARI0025I THE PROGRAM ARISQLDS IS LOADED AT 7F2078.
ARI0025I THE PROGRAM ARICMOD IS LOADED AT 905D80.
ARI0025I THE PROGRAM ARIXRDS IS LOADED AT 9CA000.
ARI0025I THE PROGRAM ARIXSXR IS LOADED AT B4A000
ARI0206D DID THE USER-ARCHIVE OF THE DIRECTORY AND 8
DBEXTENT(S) EXECUTE SUCCESSFULLY
REPLY 0(N0) OR 1(YES)
1
ARI0283I LOG ANALYSIS COMPLETE
ARI0282I LUW UNDO COMPLETE
ARI0281I LUW REDO COMPLETE
ARI0060I DATABASE MANAGER INITIALIZATION COMPLETE.
ARI0045I READY FOR OPERATOR COMMUNICATIONS
When you answer 1 to indicate that the previous backup executed successfully, the history area is updated to specify that the BACKUP process completed without an error.
If an error occurred during the BACKUP function, answer 0 and the database server will restart without the BACKUP process completing successfully.
Figure 74. Restarting the Database After BACKUP When the Process Was Not Successful
If you answered 0 to indicate that the BACKUP function did not complete successfully, you can choose to continue without the user archive or to redo the user archive. If you choose to continue without the user archive, the unsuccessful user archive is ignored. If you choose to redo the user archive, the CANCEL command stops the server and you must execute the BACKUP after the correcting the problem.
If you stop the application server using SQLEND when LOGMODE=Y, normal start up messages are displayed the next time the server is started as there is no record that you took a user archive.