Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use SHELL scripts to verify the validity of RMAN backup sets for Oracle databases

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Use SHELL scripts to verify the validity of RMAN backup sets for Oracle databases

Author: Zhao full text net name: guestart

All the Oracle databases in our production environment have been backed up by RMAN, which uses an one-week RMAN backup retention strategy. In addition to using RMAN backup, we also use Eisoo backup software for backup, which can be said to be a precaution. However, if one day, the Oracle database due to host-level hardware reasons or database-level reasons can not provide high-availability services, suppose we have lost a large part of the data, we can only use RMAN backup for recovery, and if we find that RMAN backup is invalid, then drilling into the ground and crying in the toilet will not help.

To prevent this from happening, it is necessary to verify the validity of the RMAN backup set for the Oracle database. To this end, I wrote a SHELL script specifically to verify the validity of the RMAN backup set. I put the script file in crontab's scheduled task and had it run automatically at 21:00 every night, in order to verify the validity of the RMAN backup set generated the day before.

Now, use an online Oracle database production environment to demonstrate the operation.

First, check out the most recent RMAN, as shown in the following figure

Next, take a look at the generated LOG file that verifies the validity of the RMAN backup set, as shown in the following figure

Let's take a look at the LOG file generated on March 3, 2017 as an example. The following is the result of executing the SHELL script verification, as shown in the following figure

Screenshot one

We found that the first thing to verify above is the archive log backup set in the incremental backup generated on March 2.

Screenshot two

This is followed by verifying the backup set generated by the incremental level 1 backup and the last manual archive and backup archive log backup set

Screenshot three

Because the automatic backup function of the control file is turned on in the parameter setting of RMAN, the last backup is the control file, so the last check is also the control file, hey!

As the saying goes, "if you want to do good work, you must sharpen its tools first"! Finally, let's focus on the details of rman_validate_v2.sh, a SHELL script that verifies the validity of RMAN backup sets.

Due to the excessive content of the script, it is explained in three parts below, as shown in figure 1

Explain in turn, several places marked in red boxes.

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

(2) SHELL script file name

(3) Last modified date

(4) the consideration for the use of the SH script is, of course, to ensure that after the test has passed on the test environment, it is used in the production environment.

See figure 2

Figure 2, there are three red boxes, box 1 is the absolute path where the SHELL external command to be used in the script is defined. The path on each Linux operating system may be different. Try to use "the command name that which wants to use" to find it, and then write it on it. Usually write down what you want to use. Box 2 is a string variable that defines some string variables and normal string variables about the path, and the SHELL command is enclosed in a pair of backquotes (the key below the ESC key and to the left of the number 1 key on the keyboard) (Note: the execution result of the SHELL command can only be generated by enclosing it in backquotes). Box 3 is that after using the SQLPLUS command to connect to the Oracle database, find out all the BS_ key values in the RMAN backup set generated the previous day by querying the view V$BACKUP_SET_DETAILS, and then save it to a string variable BSKEY_LIST.

See figure 3

Figure 3 has two red boxes that need to be specified. Box 1 uses a powerful AWK command to put a comma in the middle of the value of the string variable BSKEY_LIST "6046 6047 6048 6049 6050 6051 6052" (so I named the string variable of box 1 BSKEY_LIST_WITH_COMMA, meaning comma BSKEY_LIST). It looks like this format, "6046, 6047, 6048, 604, 604, 6048, 609, 6050, 6051, 6052". Box 2 is the statement that goes to the RMAN command line to verify the validity of the RMAN backup set. Validatebackupset is followed by a comma list of BS_ key values. In this format, "validate backupset6046,6047,6048,6049,6050,6051,6052 check logical;" can also use a FOR loop to read out the value of the string variable BSKEY_LIST one by one, and then execute validatebackupset 6046 check logical; to take another value, and then execute validatebackupset 6047 check logical again. Until the value of the character variable BSKEY_LIST is taken, there is no need to define the previous string variable BSKEY_LIST_WITH_COMMA. Depending on your personal preferences, I think I prefer to use it with commas.

I put the script rman_validate_v2.sh on GitHub. The URL is

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

If you think this article is helpful to you, you are welcome to follow the DBA study notes on Wechat official account: guestart. Your support is my greatest encouragement!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report