Oracle Rman backup script and automatic deletion of duplicate backup files, mongolerman

Source: Internet
Author: User

Oracle Rman backup script and automatic deletion of duplicate backup files, mongolerman

#!/bin/shsource /home/oracle/.bash_profileif [ -z $1 ]then  echo "Please Input a number,Usage: 0|1|2"  exitelse  RMAN_LEVEL=$1fiexport ORACLE_SID=xxxxexport TODAY=`date '+%Y%m%d'`export RMAN_DIR=/backup/archivelog/rman/$ORACLE_SID/$TODAY-$RMAN_LEVELmkdir -p $RMAN_DIRcd $RMAN_DIRLogFile=ora_rman_bk_$ORACLE_SID-L$RMAN_LEVEL-`date '+%Y%m%d'`.log# rman backup rman target /  msglog=$RMAN_DIR/$LogFile<<EOFdelete noprompt obsolete; CONFIGURE BACKUP OPTIMIZATION ON;CONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$RMAN_DIR/cf%F';run {allocate channel c1 type disk;allocate channel c2 type disk;backup as compressed backupset incremental level $RMAN_LEVEL filesperset 3 tag 'dbL$RMAN_LEVEL' format '$RMAN_DIR/ora_o_%d_%t%s%p%u' database skip readonly include current controlfile;sql 'alter system archive log current' ;backup(archivelog all format '$RMAN_DIR/ora_a_%d_%t%s%p%u' delete input);release channel c1;release channel c2;}list backup;exit;EOF#mail backup logmail -s "$ORACLE_SID rman L$RMAN_LEVEL backup log $TODAY"  email_name@126.com < $RMAN_DIR/$LogFile

By the way, the difference between delete noprompt obsolete and delete obsolete is noprompt: no prompt is required. In shell scripts, you do not need to confirm the "yes or no" Operation on the initiated delete command.

Set 0 4 ** 5 sh/backup/scripts/oracle/oracle_rman_bak.sh 0>/backup/archivelog/logs/rman. log 2> & 1
0 4 ** 2 sh/backup/scripts/oracle/oracle_rman_bak.sh 1>/backup/archivelog/logs/rman. log 2> & 1

Perform incremental and zero-level backup once a week.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.