Oracle database backup and restore tool written in batch

Time:2020-11-27

This is written for Oracle and can be used on different computers, because it will automatically read the environment variables of the current computer, so as to obtain the installation path of Oracle. The only deficiency is that an intermediate text file will be generated during the running process of the program, but this does not hinder the event. After the backup or restore, the generated text file and code will be automatically deleted As follows:

Copy codeThe code is as follows:
@echo off&setlocal enabledelayedexpansion
color 0a
:start
for /f “tokens=2 delims==” %%a in (‘path’) do (
set “str=%%a”
set str=!str: =+!
for %%i in (!str!) do (
set “var=%%i”
set var=!var:+= !
echo !var!>>change.txt
    for /f “delims=” %%i in (‘findstr “oracle” change.txt’) do set var=%%i
)

)

Set / P choice = 1. Backup 2. Restore 3. Press any key to exit:
if %choice%==1 goto exp
if %choice%==2 goto imp
:exp
del /q change.txt
Set / P file = please input the file name of spare parts database:
Set / p path = please enter the path to store (remember to enter colon:):
“%var%”\exp.exe smhr/smhr file=%path%\%file% full=n
Set / P choice = 1. Continue 2. Press any key to exit:
if %choice%==1 goto start
:imp
del /q change.txt
Set / P file = please drag the database file to be imported into the form:
“%var%”\imp.exe smhr/smhr file=%file% full=y
Set / P choice = 1. Continue 2. Press any key to exit:
if %choice%==1 goto start