Monday, July 30, 2007

Cron job to perform an rman backup

This script will perfom an rman backup of the database in redhat enterprise 3 and automatically delete archive logs and obsolete backups. Obsolete backups are determined by a retention policy.

. $HOME/.bash_profile
rman target / << EOF
configure controlfile autobackup on;
backup database plus archivelog delete input;
delete obsolete;
EOF


Save the script in a file on your operating system and call it using a cron job e.g

30 20 * * 1-5 sh /home/oracle/rmanbackup.sh

Will perfom a backup every 8.30 p.m of ever month of everday on monday (1) to friday (5)

Remember to run the script as an oracle user.

No comments: