Saturday, 4 July 2015

How to Create A Batch File for Scheduling Backups in Oracle on Daily, Weekly, Monthly and Yearly basis. 


Folks,  below is the script which will create a batch file to run in Windows scheduler to take backups of databases on daily, weekly, monthly basis.

For your reference, I have also attached a .BAT file screenshot.


Steps :

1) Open notepad  and paste the text provided below. 

2) In this text, database name is SCANA, so you can change your db name accordingly.

3) Change the dpdump location in text.

4) Save the changes and save as .bat file as shown in screenshot.

5) Create a task in windows scheduler and schedule the time for batch file to run.

----------------------------
 
set ORACLE_SID=SCANA
set day=%date:~0,3%
set month=%date:~4,2%
set daydate=%date:~7,2%
set year=%date:~-4%
set hour=%time:~0,1%
set minute=%time:~3,2%
set backup_date_time=%daydate%_%month%_%year%_%hour%_%minute%
expdp system/password@SCANA directory=data_pump_dir dumpfile=SCANA_%backup_date_time%.dmp logfile=SCANA_%backup_date_time%.log FULL=Y
forfiles -p "D:\app\Admin\admin\SCANA\dpdump" -s -m SCANA*.* -d -2 -c "cmd /c del @file"
 


---------------------------- 




Thanks.

 

No comments:

Post a Comment