Expdp backup script on windows with 5 day retention

<h2<EXPDP Backup on windows with 5 day retention

Following are the steps to configure the expdp logical backup script on windows platform:

Step 1: Create folder on drive D: with DBBACKUP

Step 2: Connect with sqlplus

create directory dbbackup as 'D:\dbbackup';

Step 3: Create Script save it as bat file and replace ORAPROD with your DBNAME

D:
cd D:\DBBACKUP
set oracle_home=E:\oracle\dbhome_1
set path=%ORACLE_HOME%\bin;%PATH%
set ORACLE_SID=ORAPROD
expdp \"/ as sysdba\" full=Y directory=dbbackup dumpfile=ORAPROD_%date:~4,2%_%date:~7,2%_%date:~10,4%.dmp logfile=ORAPROD_%date:~4,2%_%date:~7,2%_%date:~10,4%.log
rar m ORAPROD_%date:~4,2%_%date:~7,2%_%date:~10,4%.zip ORAPROD_%date:~4,2%_%date:~7,2%_%date:~10,4%.dmp
forfiles -p "d:\dbBackup" -s -m ORAPROD*.* -d -5 -c "cmd /c del @file"

Note: In above script forfiles command is used for delete the ORAPROD file after 5 days time period

Step 4. Copy winrar file rar.exe in the same folder. For zip operation it will work. other wise you remove the line from the script “rar m ORAPROD_%date:~4,2%_%date:~7,2%_%date:~10,4%.zip ORAPROD_%date:~4,2%_%date:~7,2%_%date:~10,4%.dmp”
If you want expdp dump file is compressed without winrar utility, you can use compress=y option of expdp

Step 5.  forfiles automatically delete files after 5 days.  -d 5, you can also increase it’s value as you required.

Advertisements

2 thoughts on “Expdp backup script on windows with 5 day retention

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s