Detailed description of automatic DB2 database backup

Source: Internet
Author: User
(1) ensure that your DB2 database has been installed and runs properly. (2)

(1) ensure that your DB2 database has been installed and runs properly. (2) Start-run the command db2cmd to open a new DB2 command window: in the "command window" of DB2, execute the following statement to create a backup and run the database db2 create tools catalog cc create new database toolsdb.

Detailed description of automatic DB2 database backup

1) ensure that your DB2 database has been installed and runs properly.

2) choose Start> Run and enter the command db2cmd to open a new db2 command window:

In the "command window" of DB2, execute the following statement to create a backup and run the database.

Db2 create tools catalog cc create new database toolsdb

The purpose is to create a database named toolsdb to store task information.

3) Open the "task Center" window, as shown in figure

4) create a task

Note that "type" and "DB2 instance and partition" are selected

On the "Command Script" tab, enter the script:

Backup database JM_DAJ online to "D: \ DB2_BAK" WITH 2 buffers buffer 1024 PARALLELISM 1 compress include logs without prompting;

This means to compress and back up the database JM_DAJ to the d: \ DB2_BAK directory (the premise is that the D: \ DB2_BAK directory already exists)

Then go to the "Schedule" tab page.

Add a time start point and select "Repeat Schedule". Note that the "RunTime permission" should also be filled in. Generally, it is administrator and the password is the password used to log on to windows.

Then you can click "OK ".

The automatic backup of DB2 has been set up and backed up once a day. Find the backup file in the "D: \ DB2_BAK" directory.

5) delete a database

When Database Backup increases day by day, the hard disk capacity will become smaller and smaller until the hard disk space capacity is full, and automatic backup cannot be performed at this time. Therefore, we must delete redundant database backup files within a certain period of time.

Create a bat file, such as db2autodel. bat, in the root directory of the C drive. The content is as follows:

C: \ WINDOWS \ system32 \ forfiles/p D: \ DB2_BAK/m *. */d-7/c "cmd/c del @ file"

In this way, the files in the D: \ DB2_BAK directory will be retained for 7 days.

Create a Task Scheduler:

Browse and find the db2autodel. bat file created under the C-drive root directory

Select to execute this task every day and click Next:

Select the start time and click Next:

Click the finish button. The system automatically deletes redundant historical database backup files every day based on the information you set.

Since then, the automatic backup and timed clearing of the DB2 database have been completed.

For Scheduled Backup of oa files, we can also create a bat file to complete: (this command needs to call WinRAR, please ensure that the system has installed WinRAR software)

Cd C: \ Program Files \ WinRAR

Winrar a-r-ibck-y d: \ DB2_BAK \ % date :~ 4,102.16.rar e: \ DAJ_OA \ Tomcat5.0 \ jmoa \*.*

This means to compress the oa package file and store it in the d: \ DB2_BAK directory. Note that E: \ DAJ_OA \ atat5.0 \ jmoa is the oa package directory in this example, the directories of different units may be different. Please modify the directory according to the actual path and add the bat file to the scheduled task to complete automatic backup of the oa file.

If the server is inserted with a mobile hard disk, you can create a new bat file to regularly copy the automatically backed up file to the mobile hard disk: xcopy d: \ db2_bak F: \ db2_bak/s/I/y means to copy the files in d: \ db2_bak to F: \ db2_bak and add the bat file to the scheduled task.

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.