Oracle automatic backup case on Linux platform (using RMAN)

Source: Internet
Author: User
There is an automatic backup script program for rman. I have previously written an automatic backup case for exp backup specific solution (Oracle automatic backup case for Linux platform (using exp tool)

There is an automatic backup script program for rman. I have previously written an automatic backup case for exp backup specific solution (Oracle automatic backup case for Linux platform (using exp tool)

There is an automatic backup script program that asks rman. I have previously written an automatic backup case for the exp backup specific solution (Oracle automatic backup case on Linux platform (using exp tool )), now I want to add the rman case.
To this end, write the following content and only record and share the process.

Environment:
Operating System: RHEL5.4
Database: Oracle 10.2.0
Related variable values:
ORACLE_BASE =/u01/app/oracle
ORACLE_HOME =/u01/app/oracle/product/10.2.0/db_1
Backup database instance name: test
Target directory of the backup:/backup_rman

The implementation process is as follows:
Step 1: Prepare the Directory
Mkdir/backup_rman
Chown oracle: oinstall/backup_rman
Chmod 755/backup_rman

Step 2: Write the backup script program
1. Create a backup script
Switch to the oracle user, create the bin directory under the oracle Home directory, and create the file rman_backup.sh
Mkdir bin
Cd bin
Touch rman_backup.sh
Chmod 755 rman_backup.sh
Edit the rman_backup.sh file and add the following content:
#! /Bin/bash
Source/home/oracle/. bash_profile
/U01/app/oracle/product/10.2.0/db_1/bin/rman target/nocatalog export file =/home/oracle/bin/rman_cmd log =/backup_rman/rman_full _ 'date + % Y % m % d % H % M '. log
2. Create a backup script file for rman
Cd ~ /Bin
Touch rman_cmd
Edit the rman_cmd file and add the following content (you can modify the content as needed ):
Crosscheck archivelog all;
Delete noprompt expired archivelog all;
Run {
Configure retention policy to recovery window of 4 days;
Configure controlfile autobackup off;
Allocate channel c1 device type disk format'/backup_rman/rman_full _ % T _ % U' maxpiecesize = 3G;
Allocate channel c2 device type disk format'/backup_rman/rman_full _ % T _ % U' maxpiecesize = 3G;
Allocate channel c3 device type disk format'/backup_rman/rman_full _ % T _ % U' maxpiecesize = 3G;
Backup database plus archivelog delete all input;
Backup current controlfile format '/backup_rman/rman _ % T_CTL _ % U ';
Backup spfile format '/backup_rman/rman _ % T_SPFILE _ % U ';
Release channel c1;
Release channel c2;
Release channel c3;
}
Crosscheck backupset;
Delete noprompt expired backup;
Delete noprompt obsolete;
Crosscheck archivelog all;
Delete noprompt expired archivelog all;


Step 3: Add a crontab to schedule a task
Use oracle users to add routine tasks:
Crontab-e
Add the following content to the new window:
0 24 ***/home/oracle/bin/rman_backup.sh
(*/3 *****/home/oracle/bin/rman_backup.sh)
Note: The brackets can be used for testing. A backup is performed every three minutes. For example, a backup is performed every 24 o'clock every day.

Step 4: perform verification:
1. The crontab is successfully verified:
Run tail-f/var/log/cron under root to monitor cron logs to ensure successful execution of crontab:
Aug 31 00:20:06 model crontab [6380]: (oracle) begin edit (oracle)
Aug 31 00:20:48 model crontab [6380]: (oracle) REPLACE (oracle)
Aug 31 00:20:48 model crontab [6380]: (oracle) end edit (oracle)
Aug 31 00:21:01 model crond [1, 26958]: (oracle) RELOAD (cron/oracle)
Aug 31 00:21:01 model crond [1, 6412]: (oracle) CMD (/home/oracle/bin/rman_backup.sh)
Aug 31 00:24:01 model crond [1, 6621]: (oracle) CMD (/home/oracle/bin/rman_backup.sh)

2. Check whether rman is executed and the execution is successful.
A. Execute ps-ef | grep rman | grep-v grep during rman execution to check whether the rman process has been started successfully.
B. Check whether the/backup_rman directory contains the files generated by the backup:
$ Oracle @ model/backup_rman> ls
Rman_20120831_CTL_0mnjvu15_1_1 rman_full_20120831_0injvtrq_1_1
Rman_20120831_CTL_0vnjvu57_1_1 rman_full_20120831_0jnjvtvs_1_1
Rman_20120831_SPFILE_0nnjvu18_1_1 rman_full_20120831_0knjvu0c_1_1
Rman_20120831_SPFILE_10njvu5a_1_1 rman_full_20120831_0lnjvu13_1_1
Rman_full_201208310021.log rman_full_20120831_0onjvu1a_1_1
Rman_full_201208310024.log rman_full_20120831_0pnjvu1e_1_1
Rman_full_20120831_0dnjvtrg_1_1 rman_full_20120831_0qnjvu1e_1_1
Rman_full_20120831_0enjvtrg_1_1 rman_full_20120831_0rnjvu1i_1_1
Rman_full_20120831_0fnjvtrg_1_1 rman_full_20120831_0snjvu4s_1_1
Rman_full_20120831_0gnjvtrp_1_1 rman_full_20120831_0tnjvu52_1_1
Rman_full_20120831_0hnjvtrp_1_1 rman_full_20120831_0unjvu55_1_1

Verification Result: the automatic rman backup task is successfully executed!

Recommended reading:

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

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.