Use RMAN to configure automatic Incremental Backup in centos

Source: Internet
Author: User

Use RMAN to configure automatic Incremental Backup in centos
System: centos 5.5
Database: oracle 11gR2
 
1. Backup Policy
Perform level 0 incremental backup on Sunday
Perform Level 2 incremental backup on Monday
Perform Level 2 incremental backup on Tuesday
Perform Level 1 incremental backup on Wednesday
Perform Level 2 incremental backup on Thursday
Perform Level 2 incremental backup on Friday
Perform Level 2 incremental backup on Saturday
 
 
2. generate three backup scripts called by rman (Level 0, level 1, level 2)
Create the required directory first
 
Mkdir-p/u01/backup/directory for storing backup scripts
 
Mkdir/u01/backup/directory for storing backups
 
Level 0 script:
[Root @ rac1 backup] # more backup_lv0. SQL
Run {
 
Allocate channel c1 type disk;
Allocate channel c2 type disk;
 
Backup incremental level 0 database
 
Include current controlfile format '/u01/backup _ % T _ % s _ % p. lv0'
Plus archivelog delete all input format'/u01/backup _ % T _ % s _ % p. arc ';
 
Release channel c1;
Release channel c2;
}
Level 1 script:
[Root @ rac1 backup] # more backup_lv1. SQL
Run {
Allocate channel c1 type disk;
Backup incremental level 1 database include current controlfile
Format '/u01/backup _ % T _ % s _ % p. lv1 ';
Release channel c1;
}
Level 2 script:
[Root @ rac1 backup] # more backup_lv2. SQL
Run {
Allocate channel c1 type disk;
Backup incremental level 2 database include current controlfile
Format '/u01/backup _ % T _ % s _ % p. lv2 ';
Release channel c1;
}
3. Create a shell program for automatic backup
[Root @ rac1 backup] # more backup. sh
#! /Bin/bash
# Edit: daniel
# Date: 2012-03-08
# Auto backup database
# Load Environment variables
 
Source/home/oracle/. bash_profile
 
Myweek = 'date + %'
Mydate = 'date + % Y % m % d'
 
Mydir =/u01/backup
 
# Sunday
 
If ["$ myweek" = "Sun"]; then
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv0. SQL
 
Fi
 
 
# Monday
 
If ["$ myweek" = "Mon"]; then
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv2. SQL
 
Fi
 
 
# Tuesday
 
If ["$ myweek" = "Tue"]; then
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv2. SQL
 
Fi
 
 
# Wednesday
 
If ["$ myweek" = "Wed"]; then
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv1. SQL
 
Fi
 
 
# Thursday
 
If ["$ myweek" = "Thu"]; then
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv2. SQL
 
 
 
Fi
 
 
# Friday
If ["$ myweek" = "Fri"]; then
 
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv2. SQL
 
Fi
 
 
# Saturday
If ["$ myweek" = "Sat"]; then
 
Rman target/msglog =$ {mydir}/backup _ $ {mydate}. log partition file =$ {mydir}/backup_lv2. SQL
 
Fi
 
4. Create a scheduled task with cron. By default, cron is automatically started at startup.
Run crontab-e to add the following statement:
00 01 *** sh/u01/backup. sh
Save and exit
(00 represents minute 01 represents the last three hours * represents the date and week, because every day is executed here, so use *
Indicates that the backup script is executed at every day)
[Oracle @ rac1 ~] $/Sbin/chkconfig -- list
NetworkManager 0: off 1: off 2: off 3: off 4: off 5: off 6: off
Acpid 0: off 1: off 2: on 3: on 4: on 5: on 6: off
Anacron 0: off 1: off 2: on 3: on 4: on 5: on 6: off
Atd 0: off 1: off 2: off 3: on 4: on 5: on 6: off
Auditd 0: off 1: off 2: on 3: on 4: on 5: on 6: off
Autofs 0: off 1: off 2: off 3: on 4: on 5: on 6: off
Avahi-daemon 0: off 1: off 2: off 3: on 4: on 5: on 6: off
Avahi-dnsconfd 0: off 1: off 2: off 3: off 4: off 5: off 6: off
Bluetooth 0: off 1: off 2: on 3: on 4: on 5: on 6: off
Capi 0: off 1: off 2: off 3: off 4: off 5: off 6: off
Conman 0: off 1: off 2: off 3: off 4: off 5: off 6: off
Cpuspeed 0: off 1: on 2: on 3: on 4: on 5: on 6: off
Crond 0: off 1: off 2: on 3: on 4: on 5: on 6: off
Check whether crond is automatically started
Note:
The permission is as follows:
[Root @ rac1 backup] # ll
Total 4932644
-Rw-r ----- 1 oracle asmadmin 162209792 Mar 9 0:00 backup_20120309_14_1.lv2
-Rw-r ----- 1 oracle asmadmin 18874368 Mar 9 0:00 backup_20120309_15_1.lv2
-Rw-r -- 1 oracle oinstall 2154 Mar 9 backup_20120309.log
-Rw-r -- 1 oracle oinstall 294 Mar 2 backup_lv0. SQL
-Rw-r -- 1 oracle oinstall 165 Mar 2 backup_lv1. SQL
-Rw-r -- 1 oracle oinstall 165 Mar 5 backup_lv2. SQL
-Rwxr-xr-x 1 oracle oinstall 1135 Mar 8 backup. sh
 
Check the mail sent by the system to oracle users
[Root @ rac1 backup] # cd/var/mail
[Root @ rac1 mail] # ls
Oracle root rpc
[Root @ rac1 mail] # more oracle
From oracle@localhost.localdomain Fri Mar 9 01:00:27 2012
Return-Path: <oracle@localhost.localdomain>
Received: from localhost. localdomain (rac1 [127.0.0.1])
By localhost. localdomain (8.13.8/8.13.8) with ESMTP id q28H0R1X000410
For <oracle@localhost.localdomain>; Fri, 9 Mar 2012 01:00:27 + 0800
Received: (from oracle @ localhost)
By localhost. localdomain (8.13.8/8.13.8/Submit) id q28H04uF000380;
Fri, 9 Mar 2012 01:00:04 + 0800
Date: Fri, 9 Mar 2012 01:00:04 + 0800
Message-Id: <201203081700.q28H04uF000380@localhost.localdomain>
From: root@localhost.localdomain (Cron Daemon)
To: oracle@localhost.localdomain
Subject: Cron <oracle @ rac1> sh/u01/backup. sh
Content-Type: text/plain; charset = UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <SHELL =/bin/sh>
X-Cron-Env: <HOME =/home/oracle>
X-Cron-Env: <PATH =/usr/bin:/bin>
X-Cron-Env: <LOGNAME = oracle>
X-Cron-Env: <USER = oracle>
 
RMAN> 2> 3> 4> 5> 6> 7>


Author ale years

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.