Oracle 11g Database Automatic backup execution script

Source: Internet
Author: User

@echo off
Setlocal enabledelayedexpansion
Title%date%%time:~,8% by Liaoning Sunray Software Technology

:: XXX Database backup
:: Define Database SID
Set SID=ORCL

:: Define user an array groups (spaces separated by each user for example: User1 user2 User3)
Set USERARR=AAA
Set PSWDARR=BBB

:: Specify the number of days to delete
Set daysago=3

:: Specify the backup path
Set Filepath=d:\oracle database backup \


:: Define script internal variables
Set Time_=%time: =0%
Set Filename=%date:~0,4%%date:~5,2%%date:~8,2%_%time_:~0,2%%time_:~3,2%.dmp
Set newdir=%date:~0,10%\

:: Create a folder named after today's date
If not exist%filepath% MD%filepath%
If not exist%filepath%%newdir% MD%filepath%%newdir%

Echo starts backup (backs up the entire database) .....

Exp%userarr%/%pswdarr%@%sid% file=%filepath%%newdir%%userarr%_%filename%

:: Delete data from N days ago
Set d=%date:~0,10%
Mshta vbscript:createobject ("Scripting.FileSystemObject"). OpenTextFile ("Temp.txt", 2,true). Write (FormatDateTime ( DATEADD ("D",-%daysago%+1, "%d%"), Vbshortdate)) (Window.close)
for/f "Tokens=1 delims="%%i in (temp.txt) do set t1=%%i
for/f "delims="%%i in (' dir/ad/b%filepath% ') does (
Set t2=%%i
Set t3=!t2:~0,10!
If!t3! LSS!t1! rd/s/q "%filepath%%%i")
del/f Temp.txt

Oracle 11g Database Automatic backup execution script

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.