Using shell scripts to verify the validity of an Oracle database Rman backup set

Source: Internet
Author: User

Use SHELL script to verify Oracle Database RMAN Validity of backup sets

author : Zhao Full text Network name : Guestart

Our production environment oracle database has been made Rman Backup, is a week of rman backup retention policy; In addition to using rman backup, we also use the number of love (Eisoo) backup software to backup, can be said to be prepared. However, if one day, oracle If the database is not available for high-availability services due to host-level hardware or database-level reasons, assuming that the data is missing a large part, we only use rman backup to restore, and if found, rman backup failed, It doesn't help to drill and cry in the toilet.

To prevent this from appearing, it is necessary to Validate the validity of the Oracle database RMAN backup set. To this end, I specifically wrote a SHELL script to verify the effectiveness of the RMAN backup set, put the script file in the crontab of the scheduled task, so that it can be automatically run every night , The purpose is to verify the effectiveness of the RMAN backup set generated the previous day .

now, with a set on the line Oracle Database production environment to demonstrate operations.

first, look at the most recent RMAN fully prepared, as shown,

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8E/47/wKiom1i7uI-Rkd13AABdXEDiUOI748.png-wh_500x0-wm_ 3-wmp_4-s_649140724.png "title=" 1.png "alt=" Wkiom1i7ui-rkd13aabdxediuoi748.png-wh_50 "/>

Next, take a look at the generated checksum The LOG file for the validity of the RMAN backup set , see,

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8E/47/wKiom1i7uMuDnoy-AAAzvMetcmo211.png-wh_500x0-wm_ 3-wmp_4-s_3250530364.png "title=" 2.png "alt=" Wkiom1i7umudnoy-aaazvmetcmo211.png-wh_50 "/>

Let's take a look at the LOG file generated for 3 months and 3 days, the following is the result of executing SHELL script validation, as shown in

One

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8E/47/wKiom1i7uQKAbnNjAADa4k8GgLQ401.png-wh_500x0-wm_ 3-wmp_4-s_2372537878.png "title=" 3.png "alt=" Wkiom1i7uqkabnnjaada4k8gglq401.png-wh_50 "/>

we found that the first checksum above was the archive log backup set in the incremental backup generated for 3 months and 2 days.

Two

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8E/47/wKiom1i7uVTyo-qxAAEDwLQqStw781.png-wh_500x0-wm_ 3-wmp_4-s_1393828525.png "title=" 4.png "alt=" Wkiom1i7uvtyo-qxaaedwlqqstw781.png-wh_50 "/>

The backup set and the last manual archive as well as the backed up archive log backup set are then verified for the incremental level 1 backup.

Three

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8E/45/wKioL1i7uZWAnWufAACMyuY4F0M887.png-wh_500x0-wm_ 3-wmp_4-s_1208161106.png "title=" 5.png "alt=" Wkiol1i7uzwanwufaacmyuy4f0m887.png-wh_50 "/>

since the RMAN parameter settings to open the control file automatic backup function, so the last backup is the control file, then the final check is also control files, hey!

As the saying goes, "工欲善其事, its prerequisite"! Finally,rman_validate_v2.sh the specifics of this SHELL script that validates the effectiveness of the Rman backup set ,

due to the excessive content of the script, the following three parts to illustrate, see Figure 1,

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8E/45/wKioL1i7uhywXQS0AACXrftVMyQ962.png-wh_500x0-wm_ 3-wmp_4-s_878420220.png "title=" 6.png "alt=" Wkiol1i7uhywxqs0aacxrftvmyq962.png-wh_50 "/>

explain in turn, a few Red Box mark the place,

(1) personal profile, including name, Emai email, technical blog URL;

(2) SHELL script file name;

(3) date of last modification;

(4) the the precautions to use with SH scripts are, of course, to ensure that testing is done in the test environment and then used in the production environment.

See figure 2,

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8E/47/wKiom1i7upui_BmhAAC1O5MJ_xk135.png-wh_500x0-wm_ 3-wmp_4-s_30459166.png "title=" 7.png "alt=" Wkiom1i7upui_bmhaac1o5mj_xk135.png-wh_50 "/>

Figure2, there are3a red box , a box1is defined in the script to be used in theSHELLthe absolute path where the external command resides, each of theLinuxthe path on the operating system may be different, try to use the "whichYou want to use the command name "to find out, and then write to the above, usually to use to write up; box2is to define a number of string variables and ordinary string variables about the path andSHELLcommand with a pair of anti-quotes (on the keyboardEsckeys below and numbers1The key to the left of the key)string variables enclosed in(Note: Only the inverted quotation marks can be used to generateSHELLexecution result of the command); Box3is to useSQLPLUScommand to connect toOracledatabase, through the query viewv$backup_set_detailsto find out what was generated the day beforeRMANall of the backup setsBs_keyvalue, and then save to a string variableBskey_list.

See figure 3,

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8E/45/wKioL1i7uwbgGWr0AABaxIZKnXE296.png-wh_500x0-wm_ 3-wmp_4-s_3299258518.png "title=" 8.png "alt=" Wkiol1i7uwbggwr0aabaxizknxe296.png-wh_50 "/>

Figure3have a2a red box requires special instructions, the box1is through strongAWKcommand to set the string variablebskey_listthe value "6046 6047 6048 6049 6050 6051 6052"in the Middle plus a comma(so I put the box1The string variable is namedBskey_list_with_comma, which means a comma-bskey_list), as in this format, "6046,6047,6048,6049,6050,6051,6052"; Box2is in the last entryRMANcommand line, verifyingRMANThe statement that the backup set is valid,Validate BackupsetFollowed by a comma.Bs_keya list of values, as in this format, "Validate backupset6046,6047,6048,6049,6050,6051,6052 check logical;"In fact, you can also use a forFollowloop to put the string variableBskey_listThe value is read out one at a time and then executed onceValidate backupset 6046 check logical;take one more value and execute it againValidatebackupset 6047 Check logical;until all the character variables areBskey_listvalue so that you don't have to define the string variable that precedes it .Bskey_list_with_commaup. See a person likes, I think with a comma this way, personal compare like and recommend use.

I took rman_validate_v2.sh This script is placed in the GitHub , the URL is

https://github.com/guestart/rman_validate/blob/master/rman_validate_v2.sh , if you need to download it.



If you feel that this article is helpful to you, please follow the public number: Guestart of the DBA Learning notes, your support is the greatest encouragement to me!


650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/8E/45/wKioL1i7u9HxNxeEAADnPdGUWRk240.jpg "title=" Subscription number QR code. jpg "alt=" wkiol1i7u9hxnxeeaadnpdguwrk240.jpg "/>

This article from the "Blue Melancholy" blog, reproduced please contact the author!

Using shell scripts to verify the validity of an Oracle database Rman backup set

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.