Thursday, November 21, 2013

My Full Export Backup Script for Windows

I want to share my full export backup script for Windows.  7 day old files are deleted at the end of the script.  I usually run this script daily through the Windows Task Scheduler.

Also as a note, I create these scripts on a redundant Windows machine where my main database is on UNIX/Linux.

I use the DATE function to generate a date-driven filename.  And the FORFILES function to delete old dump files.  Lastly, I granted sysoper account with EXP_FULL_DATABASE privileges (you may need to grant additional system privileges to the sysoper account, this is depending on what's inside the database;  examples of these are SYS.DBMS_DEFER_IMPORT_INTERNAL and SYS.DBMS_EXPORT_EXTENSION).

Here's the batch script:

exp userid=sysoper/oper@orcl file=D:\DB_backup\edctss01_fullexp_%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%.dmp log=D:\DB_backup\edctss01_fullexp_%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%.log full=y statistics=none

forfiles -p "D:\EXPORT_AREA" -s -m *.dmp /D -7 /C "cmd /c del @path"
forfiles -p "D:\EXPORT_AREA" -s -m *.log /D -7 /C "cmd /c del @path"

No comments:

Post a Comment