Scheduled automatic backup of Oracle database under Windows system

Source: Internet
Author: User
Tags echo command mkdir oracle database

Implementation objective: To avoid data loss or errors, a scheduled backup of database data

How to Implement: Oracle Export +windows Task complete

Learning methods: The Prophet, then know the reason why

Implementation process:

1. Create file Backup.bat (custom filename. bat)

@echo off

REM ###########################################################

REM # Windows Server 2003 Automatic backup batch script for Oracle database

REM ###########################################################

REM takes the current system time and may be different depending on the operating system

Set curdate=%date:~0,4%%date:~5,2%%date:~8,2%

Set curmon=%date:~0,4%%date:~5,2%

Set curtime=%time:~0,2%

REM hours if less than 10, then fill 0 in front

If "%curtime%" = = "0" Set curtime=00

If "%curtime%" = = "1" Set curtime=01

If "%curtime%" = = "2" Set curtime=02

If "%curtime%" = = "3" Set curtime=03

If "%curtime%" = = "4" Set curtime=04

If "%curtime%" = = "5" Set curtime=05

If "%curtime%" = = "6" Set curtime=06

If "%curtime%" = = "7" Set curtime=07

If "%curtime%" = = "8" Set curtime=08

If "%curtime%" = = "9" Set curtime=09

Set curtime=%curtime%%time:~3,2%%time:~6,2%

REM set owner, user name, and password

Set OWNER=ORCL

Set USER=BKTCGL

Set PASSWORD=BKTCGL

REM creates a backup directory with a directory structure of oraclebak/yyyymmdd/

If not exist "Oraclebak" mkdir Oraclebak

CD Oraclebak

If not exist "%curmon%" mkdir%curmon%

Set filename=%curmon%/%owner%_%curdate%_%curtime%. CM7

Set Explog=%curmon%/%owner%_%curdate%_%curtime%_log.log

REM invokes Oracle's EXP command to export user data

Exp%user%/%password%@%owner% file=%filename% log=%explog% owner=%user% grants=n

Exit

Note:

1.bat files can be double-clicked or executed directly at the command line, check correctly or not

2. Can comment out exit when checking

3. The above file implementation creates the folder by month, builds the backup file by the time

2. Create Windows Tasks

Steps:

Start-> All Programs-> attachments-> System Tools-> Task Scheduler-> Operations-> Create basic tasks

-> Task Name Enter "Oracle_backup" (custom task Name), perform this task select every day, next

-> start 12:00, start date 2012-7-11, next-> (Start program) next

-> in the browse to find the Backup.bat file just written > Next > Complete

Note:

1. Under the Mission plan, a new task plan called "Oracle_backup" indicates that it has been configured.

2. Different systems have a slightly different mission plan, but the basic changes, do not do one by one cases

Issue: System Warning "a new task has been created, but may not run because account information cannot be set." The specified error is: Ox80041315: The Task Scheduler service is not running

Reason: The computer's Task Scheduler service did not start up.

Workaround: Start > All Programs > Admin tools > Services, find the "Task Scheduler" service and discover that the startup type is disabled.

Right-click to change to Automatic, start it up, and then add a task schedule again.

3. Simple explanation

1. Bat: is a DOS batch file. A batch file is an unformatted text file that contains one or more commands. Type the name of the batch file at the command prompt, or double-click the batch file, and the system calls Cmd.exe to run them one at a time in the order in which the commands appear in the file.

2. Echo command: Turn on echo or turn off request echoing, or display a message.

3. @ Command: Indicates a command that does not appear after @

4. Rem command: Comment command

5. If command: If indicates that the condition is judged to meet the stipulated conditions, so as to decide to execute different orders.

6. Exit: Exit command line

7. Grants: is the meaning of permission, in the target database you exported may have some tables such as SELECT permissions, etc. assigned to other users.

Export these permissions when "Grants=y" is exported and import those permissions when importing them.

The "grants=n" permission is not imported.

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.