This note didn't write much, just skip some.
::2. Database Expired Backup DeleteEcho.Echo.EchoSecond, the expired backup file is being purged ...REMWScript.Echo is the VBS syntax, which is equivalent to alertREM> is a special character, so you need to use the escape symbol ^> for the for command, including ^&, which is also escaped &REM//nologo Screen output: Prevent logo display:no Banner 'll be shown at execution time for/F "tokens=1,2,3 delims=-"%%a in ('EchoWScript.Echo Date-!bak_lot! ^>t~.vbs ^& cscript//nologo t~.vbs ^&delT~.vbs ') Do(Sety=%%a&Setm=%%b&SetD=%%cif%%b LSS 10SetM=0%%bif%%c LSS 10SetD=0%%c)REMhere-the string connectorSetDatee=!y!-! m!-! d! for%%i in (1,2,3,4,5,6,7,8,9) Do(SetOra[%%i]>nul 2>nul&& (SetOra_cur= for/F "Usebackq delims==. Tokens=1-3 "%%a in ('SetOra[%%i] ') Do SetOra_cur=%%bSetOra_usr=Setora_net= for/F "delims=/"%%a in ('Echo!ora_cur! ') Do SetOra_usr=%%a for/f "[email protected] tokens=2"%%a in ('Echo!ora_cur! ') Do Setora_net=%%aSetCur_dir=!bak_dir!\!ora_net!__!ora_usr! for/F "tokens=*"%%x in ("!cur_dir!") Do SetCur_dir=%%~fxEchoCheck that today's backup was successful no >nulSetfnm_pre=!cur_dir!\!ora_net!__!ora_usr!__!Date: ~0,4!!Date: ~5,2!!Date:~8,2!-&SetToday_success=0REMdir/b only display filenames and extensions, even in empty format (no header information or summary) dir!fnm_pre!*.dmp!fnm_pre!*.zip!fnm_pre!*.rar/b >nul 2>nul &&SetToday_success=1if"!today_success!" = = "1" (EchoDetermine if folder conditions meet >nul for%%a in (!cur_dir!\*.dmp,!cur_dir!\*.log,!cur_dir!\*.zip,!cur_dir!\*.rar) Do(EchoDetermine if the file name condition meets >nulSetn=%%a&Setn=!n:~-17,-9!&Setn=!n:~0,4!-! n:~4,2!-! n:~6,2! Sett=%%~taSetfiledate=!t:~0,10! if"!n!" =="! filedate! " (EchoDetermine if time conditions meet >nulif! filedate! Leq%datee% (Echo%Date: ~0,10%% Time: ~0,8% Delete expired backup%%aEcho%Date: ~0,10%% Time: ~0,8% Delete Expired backup%%a>>!cur_dir!\delete.Logdel/q "%%a"))))Else(Echo%Date: ~0,10%% Time: ~0,8% [!ora_net!__!ora_usr!] Because today's backup did not succeed, temporarily do not delete expired files! Echo%Date: ~0,10%% Time: ~0,8% [!ora_net!__!ora_usr!] Because today's backup did not succeed, temporarily do not delete expired files! >>!cur_dir!\delete.Log) ))::3. Complete the exitEcho.Echo.EchoThird, the backup operation is complete, is about to exit. Ping-nTen 127.1 >nul 2>nulExit::================================= above is the backup program =================================::================================= The following is the hypervisor =================================REMInitialize title and color: InitModeCon cols=100 lines=40title Oracle Auto Backup Color 0e::Copy to Windows directoryREM%0 is the actual command thatREM%~fn (where N is the parameter on the command line you ' re interested in)Copy"%~f0" "%windir%\oracleautobackup\oracleautobackup.bat" >nul 2>nul::registering a scheduled task: RegtasksREMSC config (service name) start= Auto (note: start= has a space behind it.)sc config ScheduleStart= Auto >nul 2>nulat|Find"The service has not started" >nul 2>nul&& (Net StartScheduleif not!ERRORLEVEL!==0 (EchoTask scheduler^ (scheduled task ^)The service failed to start and the program is about to exit! Pause>nulGoto Exit))Setjob_tmr=!bak_hou!:0 0if!bak_hou! LSS 10Setjob_tmr=0!bak_hou!:0 0At !job_tmr!/every:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31%windir%\ Oracleautobackup\oracleautobackup.bat-Backup>nul 2>nul for/F "USEBACKQ"%%i in ('dir%windir%\tasks\at*.job/b/o:d`) Do Setlastat=%%idel%windir%\tasks\oracle automatic backup. Job >nul 2>nulRename%windir%\tasks\!lastat! Oracle automatic Backup.Job::Save configuration file: SaveconfigEcho!bak_hou!>%configfile%Echo!bak_lot!>>%configfile%Echo!bak_dir!>>%configfile% for%%i in (1,2,3,4,5,6,7,8,9) Do(SetOra[%%i]>nul 2>nul&& (SetOra_cur= for/F "Usebackq delims==. Tokens=1-3 "%%a in ('SetOra[%%i] ') Do SetOra_cur=%%bPager : Str_base64"!ora_cur!"if not"!val!" ==""Echo!val!>>%configfile%))::Preparing the database configuration stringSetOra_str= for%%i in (1,2,3,4,5,6,7,8,9) Do(SetOra[%%i]>nul 2>nul&& (SetOra_cur= for/F "Usebackq delims==. Tokens=1-3 "%%a in ('SetOra[%%i] ') Do SetOra_cur=%%bSetOra_usr=Setora_net= for/F "delims=/"%%a in ('Echo!ora_cur! ') Do SetOra_usr=%%a for/f "[email protected] tokens=2"%%a in ('Echo!ora_cur! ') Do Setora_net=%%aSetOra_str=!ora_str!%%i.! ora_usr!/******@!ora_net!;))
BAT scripting Learn -6:oracle automatic backup restore script