Apply RMAN Oracle Database In Reality

Tram Ho

1. WHAT IS RMAN?

RMAN (Recovery Manager) is a data backup and recovery tool built into the Oracle database management system. RMAN enables DBAs to perform backup, restore, and recovery operations of Oracle databases efficiently.

RMAN features include full or partial database backup, restore from previous backups, restore database objects from backup, and copy integrity check backup.

To use RMAN, users can connect to RMAN using SQL*Plus or by using a command file or a script stored in the RMAN database. Basic RMAN commands include STARTUP, BACKUP, RESTORE, and RECOVERY. RMAN can also be configured via configuration parameters to adjust backup and restore operations.

In Oracle systems, RMAN is the recommended data backup and recovery tool to ensure database integrity and reliability.

The above paragraph is the GPT chat it wrote. It’s easy to understand, isn’t it?

2. USE RMAN IN REALITY

I’m sure that when you search in google, you always come across very general RMAN sentences. The real thing when I want to find a certain RMAN command that can backup in a folder I want is almost rare to find. So, after some time asking questions and researching, I will close the following orders:

2.1 BACKUP FULL DATABASE in a folder

SYNTAX

after the word FORMAT will be the path and filename of the backup RMAN %T: Year-Month-Day (Should be at the top to make it easier to see the backup date of the file) %d: Database SID name %f : Fixed file name ID ( can be replaced with another option) options of the file you can refer to the following page to understand more here

However, the above command is just a command to understand how to backup to a directory

In the project, I use a few more lines to get enough information for a backup as follows:

The above paragraph will backup the following 4 types of files:

Backup datafile Backup archivelog Backup spfile Backup controlfile (What are these files for, I will write in another post.)

Also add COMPRESSED to compress files for lightweight.

Usually when restoring or duplicating the database, I will fully prepare these files to avoid the situation that the restore is missing the file.

2.2 COMBINING SCRIPT BASH WITH RMAN

Normally, I will create a .sh file. Here I set it as backup.sh

Content

The first is to declare the log file so that when it is finished, we will monitor whether the RMAN implementation is successful or not.

1 The next file is the rman file. As above where cmndfile=backup_full.rman

The content is the paragraph that I described above

Now you also understand that when we run the sh /backup.sh command, the backup.sh file will execute the backup_full.rman file to perform the backup of RMAN and write to the LOGFILE variable for us to monitor.

2.3. APPLICATION MORE AUTOMATION WITH CRONTAB

Crontab is an application in the Linux operating system that allows users to plan and automate routine or recurring tasks at specific intervals. Normally the crontab syntax looks like this:

Type crontab -l to list scheduled jobs You can see 40 14 * * * – This is the time, here it is understood that every day at 14:40 will use user oradev to run backup_rman.sh file in directory /opt/scripts. So we will use crontab to run the command every day at a certain time, usually in the evening, and run the backup.sh command

So the sequence is as follows

crontab (scheduling) > run backup.sh > run backup_full.rman > view log

3. END

Thus, we have gone through a very quick way to use RMAN to schedule daily backups, knowledge here requires a linux background and a certain oracle database, it will be a bit difficult for those who are just starting out, however, I myself think it will be helpful for those who are looking for this problem. If you find it interesting and useful, please comment to let me know. For more cool stuff, check out this channel:

Blog: https://beatcomputer.com/

Youtube: https://www.youtube.com/channel/UCeLTZuOxo15vR-aEXbfWMUg

Share the news now

Source : Viblo