Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Windows full + incremental backup script bat

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

@ set ORACLE_HOME=D:\ app\ Administrator\ product\ 11.2.0\ dbhome_1

@ rem echo% ORACLE_HOME%

@ set ORACLE_SID=orcl

@ rem echo% ORACLE_SID%

@ set NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK

@ rem echo% NLS_LANG%

@ set PATH=%ORACLE_HOME%\ bin

@ rem echo% PATH%

@ set RMAN=%ORACLE_HOME%\ BIN\ rman.exe

@ rem * obtain system time and intercept yyyy-dd-mm * *

@ rem* if the time obtained is incorrect, please modify the system time format yyyy-mm-dd dddd**

@ rem MONTH=%date:~0,10%

@ set MONTH=%date:~0,4%%date:~5,2%%date:~8,2%

@ set BACKUP_DIR=C:\% MONTH%

@ IF NOT EXIST% BACKUP_DIR%

Mkdir BACKUP_DIR%

)

@ set RQ=%date:~0,4%%date:~5,2%%date:~8,2%

@ set RMAN_LOG_FILE=%BACKUP_DIR%\ rman_%RQ%.log

@ rem echo% RMAN_LOG_FILE%

@ rem * modify the connection rman according to the actual situation * *

@ rem TARGET_CONNECT_STR=/

@ set DAY=%date:~12,13%

@ REM level 0 backup is a full library backup. Level 1 is the data changed after backing up level 0, and level 2 is the data changed after backing up level 1 or level 0.

@ REM if the previous backup is level 1, then back up the modified data after that. If the previous backup is level 0, then back up the data after level 0.

@ echo = started on% DATE% = > >% RMAN_LOG_FILE%

@ set BACKUPTYPE=incremental level 2 database

@ set NAME=L2_%%d_%%T_%%s_%%U

@ if "% DAY%" EQU "one" (

Set BACKUPTYPE=incremental level 2 database

Set NAME=inc2_%%d_%%T_%%s_%%U

Set ARCHIVE=arch3_%%d_%%T_%%U

)

@ if "% DAY%" EQU "two" (

Set BACKUPTYPE=incremental level 2 database

Set NAME=inc2_%%d_%%T_%%s_%%U

Set ARCHIVE=arch3_%%d_%%T_%%U

)

@ if "% DAY%" EQU "three" (

Set BACKUPTYPE=incremental level 1 database

Set NAME=inc1_%%d_%%T_%%s_%%U

Set ARCHIVE=arch2_%%d_%%T_%%U

)

@ if "% DAY%" EQU "four" (

Set BACKUPTYPE=incremental level 2 database

Set NAME=inc2_%%d_%%T_%%s_%%U

Set ARCHIVE=arch3_%%d_%%T_%%U

)

If "% DAY%" EQU "five" (

Set BACKUPTYPE=incremental level 2 database

Set NAME=inc2_%%d_%%T_%%s_%%U

Set ARCHIVE=arch3_%%d_%%T_%%U

)

@ if "% DAY%" EQU "six" (

Set BACKUPTYPE=incremental level 2 database

Set NAME=inc2_%%d_%%T_%%s_%%U

Set ARCHIVE=arch3_%%d_%%T_%%U

)

@ if "% DAY%" EQU "Day" (

Set BACKUPTYPE=incremental level 0 database

Set NAME=full0_%%d_%%T_%%s_%%U

Set ARCHIVE=arch0_%%d_%%T_%%U

)

@ REM backup format'e:\ backup\ dbL0_%d_%T.arc' archivelog all delete input

@ rem echo backup% BACKUPTYPE% include current controlfile

@ rem echo sql "ALTER SYSTEM ARCHIVE LOG CURRENT"

@ (

Echo run {

Echo allocate channel Channel1 type disk format'% BACKUP_DIR%\% NAME%'

Echo allocate channel Channel2 type disk format'% BACKUP_DIR%\% NAME%'

Echo allocate channel Channel3 type disk format'% BACKUP_DIR%\% NAME%'

Echo allocate channel Channel4 type disk format'% BACKUP_DIR%\% NAME%'

Echo backup section size 4G filesperset 1% BACKUPTYPE% include current controlfile

Echo sql "ALTER SYSTEM ARCHIVE LOG CURRENT"

Echo backup format'% BACKUP_DIR%\% ARCHIVE%' archivelog all delete input

Echo backup current controlfile format'% BACKUP_DIR%\ ctl_%d_%T_%s_%%U'

Echo}

) |% RMAN% target / nocatalog msglog'% RMAN_LOG_FILE%'

@ set ERRLEVEL=%ERRORLEVEL%

@ if% ERRLEVEL% NEQ 0 @ goto err

@ set LOGMSG= "backup successful!"

@ goto end

: err

@ set LOGMSG= "backup failed, please try again!"

: end

@ echo # > > RMAN_LOG_FILE%

@ echo =% LOGMSG% on% DATE% = > >% RMAN_LOG_FILE%

@ endlocal

@ REM End of Main Program--

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report