An example of automatic RMAN backup script

Source: Internet
Author: User

1. Oracle scheduled task:

Crontab-e

* ***/Home/oracle/workspace/scripts/bk_main.sh>/home/oracle/workspace/log/bk_err.log 2> & 1

2. Main Control Program

/Home/oracle/workspace/scripts/bk_main.sh

#! /Bin/bash

 

Dat = 'date + '% m''

 

If ($ dat = 0 ))

Then

/Home/oracle/workspace/scripts/bk _. sh 0

Elif ($ dat % 50 = 0 ))

Then

/Home/oracle/workspace/scripts/bk _. sh 2

Elif ($ dat % 40 = 0 ))

Then

/Home/oracle/workspace/scripts/bk _. sh 2

Elif ($ dat % 30 = 0 ))

Then

/Home/oracle/workspace/scripts/bk _. sh 1

Elif ($ dat % 20 = 0 ))

Then

/Home/oracle/workspace/scripts/bk _. sh 2

Elif ($ dat % 10 = 0 ))

Then

/Home/oracle/workspace/scripts/bk _. sh 2

Fi

3. Detailed backup script description: 'date + '% Y % m % d % k % m' | awk' {print $1 $2} ''is in the yyyymmddhh24mi format of the current time.

/Home/oracle/workspace/scripts/bk _. sh

#! /Bin/bash

# This is a import statement.

PATH = $ PATH: $ HOME/bin

 

Export PATH

Export ORACLE_SID = dex

Export ORACLE_BASE =/u01/apps/oracle

Export ORACLE_HOME = $ ORACLE_BASE/product/11gr2/db_1

Export PATH = $ ORACLE_HOME/bin: $ PATH

# Use awk to cut the space char

Timst = 'date + '% Y % m % d % k % m' | awk' {print $1 $2 }''

# Use for debug

# Echo $ timst

# Create a directory like 201112140112

Mkdir/u01/backup/DEX/backups/$ timst

# Rman backup scripts

Rman target sys/xiaojun @ dex log =/home/oracle/workspace/log/rmanlog/rman _ $ timst <EOF

Run {

Allocate channel dev1 type disk;

Allocate channel dev2 type disk;

Backup incremental level 1 database format'/u01/backup/DEX/backups/$ timst/bk _ % t _ % s' plus archivelog format'/u01/backup/DEX/backups/ $ timst/arc _ % t _ % s' delete all input;

Crosscheck backup;

Delete noprompt obsolete;

Delete noprompt expired backup;

}

EOF


Do not forget to create a directory.

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.