In our previous post, we already discussed about the RMAN utility and oracle database backup types. In this article, we are going to discuss RMAN utility configuration and create a backup oracle database using RMAN.
RMAN backup configuration
Before we can take the backup, we need to set up certain RMAN parameters. For instance, for the length of time, you wish to keep the RMAN backup, etc.
Before changing any configuration, use the following command to display the current RMAN configuration settings.
For connecting to RMAN Do the following on your command prompt. This will bring you to the RMAN> command prompt. From here you are able to execute every RMAN command.
[oracle@digital ~]$ rman target/ Recovery Manager: Release 184.108.40.206.0 - Production on Thu Mar 24 14:14:16 2022 Version 220.127.116.11.0 Copyright (c) 1982, 2021, Oracle and/or its affiliates. All rights reserved. connected to target database: ORA21C (DBID=3376213612)
Check RMAN current configuration
Using the below command you can check the current RMAN configuration.
RMAN> show all; using target database control file instead of recovery catalog RMAN configuration parameters for database with db_unique_name ORA21C are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/dbs/snapcf_ora21c.f'; # default
Configure RMAN backup location
If you want to configure the RMAN backup location use the below command to set it.
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/backup/full_%u_%s_%p';
Configure Retention Period
Then, you must decide how long you wish to keep the backup. When RMAN makes a backup it will delete all backups more than the retention duration. In the following scenario, I’m setting my retention time as seven days, which will preserve a DB backup for seven days.
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
If you want to clear all the above settings then use the clear parameter to set these parameter values default.
RMAN> CONFIGURE RETENTION POLICY CLEAR;
RMAN store the backups in backup sets that are nothing more than several files that include the database backup information. Only RMAN is aware of the structure of these backup sets. If you back up the contents of an Oracle DB by using RMAN it is the only way to ensure that RMAN is able to understand this backup file and then restore it.
Using the below command you can create the database backup with backupsets.
RMAN> BACKUP AS BACKUPSET DATABASE
Create full database backup with archivelogs.
RMAN> BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;
Create a specific tablespace backup using the below command.
RMAN> BACKUP AS BACKUPSET TABLESPACE USERS;
Create RMAN backup with TAG
If you are creating database backups frequently, it will be easy to understand the backup with their name. So we can assign a tag (name) to a particular backup, which will be helpful during the database recovery or we can check it easily with the list command.
The below command is used to assign a tag to backup.
RMAN> BACKUP AS BACKUPSET TAG 'DAILY_BACKUP_USERS_TBLS_ONLY' TABLESPACE USERS;
Change RMAN backup file format
If you want to create the backup files in a specific format, then you need to change the backup format in the RMAN configuration as shown in the below command.
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backup/rman/full_devdb_bk_%u_%s_%p';
In the above screenshot, you can see the old configuration and new configuration.
Let’s create a new backup with the new configuration.
This time you can see the backup format is changed.
Compress RMAN backup
In a real-time environment, if the database size is big and you try to create the RMAN backup it is the almost same size as the database. So in this situation, we should perform a compressed backup of the database. The below command helps us to create a database compressed backup.
RMAN> BACKUP AS COMPRESSED BACKUPSET TAG 'FULL_USER_TBLS_BK_ONLY' TABLESPACE USERS; OR RMAN> BACKUP AS COMPRESSED BACKUPSET FORMAT '/u01/backup/full_ocpdb_bk_%u_%s_%p' DATABASE;
Check All RMAN backup list
On the RMAN prompt, you can check all the backup lists using the below command.
RMAN> LIST BACKUP SUMMARY;
The above command shows the complete details about the RMAN backup.
AUTOMATICALLY KILL INACTIVE SESSIONS
Upgrade Oracle 11g to 19c using AutoUpgrade utility
Check the Patch Applied to the Oracle Database