Oracle11g Backup script with 7 days retention policy for Windows
Step 1 Create a DIRECTORY EXPDPDUMPBACKUP
CREATE DIRECTORY EXPDPDUMPBACKUP AS 'D:\Backup\Daily_EXPDP_Backup';
GRANT READ, WRITE ON DIRECTORY EXPDPDUMPBACKUP TO system;
Step 2 Create a (.bat) file with name backup_script.bat
Here is you need to change the ORACLE_SID,ORACLE_HOME,ORACLE_BASE,USER NAME/PASSWORD
as per your configuration.
@ECHO OFF
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%b-%%a)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
set mytime=%mytime: =0%
set ORACLE_SID=orcl
set ORACLE_HOME=D:\oracle\product\11.2.0\dbhome_1
set ORACLE_BASE=D:\oracle\oradata\
set PATH=%ORACLE_HOME%\bin
set BACKUPPATH=D:\Backup\Daily_EXPDP_Backup
forfiles /p "D:\Backup\Daily_EXPDP_Backup" /m * /d -7 /c "cmd /c rd /s /q @path"
cd %BACKUPPATH%
mkdir "D:\Backup\Daily_EXPDP_Backup\%mydate%_%mytime%"
rem %ORACLE_HOME%\BIN\expdp
expdp USER/*****@orcl directory=EXPDPDUMPBACKUP Full=Y dumpfile=backup_%mydate%_%mytime%.dmp logfile=log_%mydate%_%mytime%.log
cd %BACKUPPATH%
move D:\Backup\Daily_EXPDP_Backup\Backup_%mydate%_%mytime%.dmp D:\Backup\Daily_EXPDP_Backup\%mydate%_%mytime%\
move D:\Backup\Daily_EXPDP_Backup\log_%mydate%_%mytime%.log D:\Backup\Daily_EXPDP_Backup\%mydate%_%mytime%\
Step 1 Create a DIRECTORY EXPDPDUMPBACKUP
CREATE DIRECTORY EXPDPDUMPBACKUP AS 'D:\Backup\Daily_EXPDP_Backup';
GRANT READ, WRITE ON DIRECTORY EXPDPDUMPBACKUP TO system;
Step 2 Create a (.bat) file with name backup_script.bat
Here is you need to change the ORACLE_SID,ORACLE_HOME,ORACLE_BASE,USER NAME/PASSWORD
as per your configuration.
@ECHO OFF
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%b-%%a)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
set mytime=%mytime: =0%
set ORACLE_SID=orcl
set ORACLE_HOME=D:\oracle\product\11.2.0\dbhome_1
set ORACLE_BASE=D:\oracle\oradata\
set PATH=%ORACLE_HOME%\bin
set BACKUPPATH=D:\Backup\Daily_EXPDP_Backup
forfiles /p "D:\Backup\Daily_EXPDP_Backup" /m * /d -7 /c "cmd /c rd /s /q @path"
cd %BACKUPPATH%
mkdir "D:\Backup\Daily_EXPDP_Backup\%mydate%_%mytime%"
rem %ORACLE_HOME%\BIN\expdp
expdp USER/*****@orcl directory=EXPDPDUMPBACKUP Full=Y dumpfile=backup_%mydate%_%mytime%.dmp logfile=log_%mydate%_%mytime%.log
cd %BACKUPPATH%
move D:\Backup\Daily_EXPDP_Backup\Backup_%mydate%_%mytime%.dmp D:\Backup\Daily_EXPDP_Backup\%mydate%_%mytime%\
move D:\Backup\Daily_EXPDP_Backup\log_%mydate%_%mytime%.log D:\Backup\Daily_EXPDP_Backup\%mydate%_%mytime%\
No comments:
Post a Comment