Monday, March 24, 2014

Backup Oracle db and save it into a shared folder [Windows]

1. create window batch file (paste the content below in to text editor and save as

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
rem set timestr=%d:~6,4%%d:~3,2%%d:~0,2%%t:~0,2%%t:~3,2%
set datestr=%d:~6,4%%d:~0,2%%d:~3,2%
set timestr=%t:~0,2%%t:~3,2%

@echo %datestr%-%timestr%
@echo %datestr%
@echo %timestr%
exp db_username/db_password@db_schema file="\\ip_address\shared\oracle\dump_%datestr%_%timestr%.dmp" log="\\ip_address\shared\oracle\log_%datestr%_%timestr%.log"


***replace db_username, db_password, db_schema,ip_address(where you want the dump and log files generated to)
***if you want to generate the dump & log file same location as the .bat file, replace with the line below:
file="filename.dmp" log="logname.log"
2. paste it into db server
3. set a task scheduler at "Control Panel->Administrative Tools and open the Task Scheduler"

No comments: