I also want to share my Linux full export backup script. The script accepts the instance name as a parameter for servers that uses multiple instances.
Here's the script:
#!/bin/sh
# Set Environment Variable
. /home/oracle/.bash_profile
# Set Oracle SID
export ORACLE_SID=$1
exp full=y userid=\"/ as sysdba\" statistics=none file=/oracle/flash_recovery_area/exportArea/full_$1_$(date +\%Y-\%m-\%d).dmp log=/oracle/flash_recovery_area/exportArea/full_$1_$(date +\%Y-\%m-\%d).log
My CRONTAB entry are as follows:
SHELL=/bin/bash
### DELETE OLD DUMP FILES
0 23 * * * find /oracle/flash_recovery_area/exportArea -type f -mtime +6 -exec rm -f {} \\\;
### FULL EXPORT
0 2 * * * /oracle/flash_recovery_area/scripts/full_export.sh edctss01
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"
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"
Subscribe to:
Posts (Atom)