Simple batch file for Oracle database backup

Hi guys
We are too busy now days. Issues @work keeping us working around the clock and giving us hardly any time to update this blog. Quite recently, we decided to expand this forum with more Oracle technology related posts, as we realize, we get maximum traffic towards the posts related to Oracle.

To begin with, we are providing a simple script for exporting the entire database using “system” user today for Microsoft Windows based implementation. This batch file exports a .dmp file to a user specified directory.

FOR /F "tokens=2-4 delims=/ " %%a IN ('date/t') DO exp system/password@connectionstring full = y file=d:\backup\exp_%%b%%a%%c.dmp

Save this script inside a .bat or .cmd file (eg: myorabackupdaily.bat or myorabackupdaily.cmd). An Administrator can easily create a scheduled job to insure that the batch file runs everyday at a particular time. Preferably during nights while transactions are none or less. Particularly, there is no need to shutdown the database in order to facilitate the export.

Once exported to .dmp file, it should bear a nomenclature as following:
exp_22012011.dmp

exp -> Export
22012011-> Date stamp

hope this article/ batch file is useful for few out there.

For Windows7bugs,

Admin

Single batch file for starting and stopping Oracle services

Quite a while I tried to compile a batch file which could start or stop oracle services based on their running status. At last, by altering few codes found through google search, I managed to make one. Below you can find it.
Update: Added prompt(s), bracketing in order to make the script work on Windows 8.x

You must change “net start ” with your installation specific service names!


@echo off
sc query "OracleOraDb10g_home1TNSListener" | findstr /i running
IF "%ERRORLEVEL%"=="0" (GOTO :RUNNING) ELSE (GOTO :STOPPED)

:STOPPED
set /P c=Oracle Services are not running, you want to start them now[Y/N]?
if /I "%c%" EQU "Y" goto :start_them

:start_them
net start "OracleOraDb10g_home1TNSListener" | sc query "OracleServiceSCT" | findstr /i running

IF NOT "%ERRORLEVEL%"=="0" (net start OracleServiceSCT)

GOTO :END

:RUNNING

set /P c=Oracle Services are running, you want to stop them now[Y/N]?

if /I "%c%" EQU "Y" goto :stop_them

:stop_them
net stop "OracleOraDb10g_home1TNSListener" | sc query "OracleServiceSCT" | findstr /i running
if "%ERRORLEVEL%"=="0" (net stop OracleServiceSCT)
GOTO :END

:END

Pause

Just copy and paste the code inside a text file and change the extension to “.cmd” or “.bat”. Make sure to “Run as administrator” if UAC is enabled.

Hope this bit of code is useful for those developers who do not want to strain the limited resources they have with their notebooks/laptops and need the local databases only upon demand.

for Windows7bugs, raj.