Oracle RMAN ( Recovery Manager ) Backup Tutorials -3

Hi,

I will continue to tell you about the RMAN (Recovery Manager) tool in this third article of my tutorial series .

Oracle RMAN2

 

As I mentioned in my following articles, RMAN is able to Backup Database both Online and Offline mode. Now let’s see how these are done and what commands are used.

 

 

Full Backup in Online Mode: The database must be in Archivelog mode in order to take full backup of database with RMAN.

If your database is not in archivelog mode, you will get following errors. You should change your database  from noarchivelog mode to archivelog mode with following article.

[oracle@MehmetSalih ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Mon Mar 25 17:16:59 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

connected to target database: DEVECI19 (DBID=4027228950)

RMAN> backup database;

Starting backup at 25-MAR-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=54 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 03/25/2019 17:17:06
RMAN-06149: cannot BACKUP DATABASE in NOARCHIVELOG mode

RMAN>



  

 

Check your database if it is in archivelog mode with following article.

 

 

 

Full Backup of Oracle database 19c in Archivelog mode can be taken with the following command.

 

[oracle@MehmetSalih ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Mon Mar 25 17:22:24 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

connected to target database: DEVECI19 (DBID=4027228950)

RMAN> backup database;

Starting backup at 25-MAR-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=73 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/19c/DEVECI19C/system01.dbf
input datafile file number=00003 name=/oradata/19c/DEVECI19C/sysaux01.dbf
input datafile file number=00004 name=/oradata/19c/DEVECI19C/undotbs01.dbf
input datafile file number=00007 name=/oradata/19c/DEVECI19C/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-MAR-19
channel ORA_DISK_1: finished piece 1 at 25-MAR-19
piece handle=/oradata/install/dbs/01ttb9qq_1_1 tag=TAG20190325T172233 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 25-MAR-19

Starting Control File and SPFILE Autobackup at 25-MAR-19
piece handle=/oradata/install/dbs/c-4027228950-20190325-00 comment=NONE
Finished Control File and SPFILE Autobackup at 25-MAR-19

RMAN>

 

It is not preferred to take Full backup with the above command, because Backup location is not specified. After the fresh installation of Oracle Databases, the default path for the backup is $ORACLE_HOME/dbs location.

In the case of very large databases, you should not take backup with the above command because backup process will be stopped because of Oracle home disk space will be full, so when the backup command is taken instead of the above command, the following command is preferred.

 

  [oracle@MehmetSalih ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Mon Mar 25 17:31:47 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DEVECI19 (DBID=4027228950)

RMAN> backup database format '/u01/backup/FULL_DATABASE_%d_%t_%s.rman';

Starting backup at 25-MAR-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=74 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/19c/DEVECI19C/system01.dbf
input datafile file number=00003 name=/oradata/19c/DEVECI19C/sysaux01.dbf
input datafile file number=00004 name=/oradata/19c/DEVECI19C/undotbs01.dbf
input datafile file number=00007 name=/oradata/19c/DEVECI19C/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-MAR-19
channel ORA_DISK_1: finished piece 1 at 25-MAR-19
piece handle=/u01/backup/FULL_DATABASE_DEVECI19_1003858311_3.rman tag=TAG20190325T173150 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 25-MAR-19

Starting Control File and SPFILE Autobackup at 25-MAR-19
piece handle=/oradata/install/dbs/c-4027228950-20190325-01 comment=NONE
Finished Control File and SPFILE Autobackup at 25-MAR-19

RMAN>

 

 

Full Backup in the Offline Mode: Take full backup of Database in offline mode means close database and open database in mount mode and take backup mean. This method of backup is not the preferred method in the critical systems that we call mission critics, but I still want to tell this method because it is useful to know. In offline mode, I perform a full backup 3 steps as follows.

 

 

Step 1: First shutdown database and open it in mount mode as follows.

[oracle@MehmetSalih ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Mar 25 17:37:18 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.2.0.0.0

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.2.0.0.0
[oracle@MehmetSalih ~]$




  [oracle@MehmetSalih ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Mon Mar 25 17:38:01 2019
Version 19.2.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area 1140849896 bytes

Fixed Size 8895720 bytes
Variable Size 838860800 bytes
Database Buffers 285212672 bytes
Redo Buffers 7880704 bytes

 

Step 2: After shuting down database consistently,  I connect to the RMAN tool and run the same as Online full backup command like following.

RMAN> backup database format '/u01/backup/FULL_DATABASE_%d_%t_%s.rman';

Starting backup at 25-MAR-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/19c/DEVECI19C/system01.dbf
input datafile file number=00003 name=/oradata/19c/DEVECI19C/sysaux01.dbf
input datafile file number=00004 name=/oradata/19c/DEVECI19C/undotbs01.dbf
input datafile file number=00007 name=/oradata/19c/DEVECI19C/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-MAR-19
channel ORA_DISK_1: finished piece 1 at 25-MAR-19
piece handle=/u01/backup/FULL_DATABASE_DEVECI19_1003858739_5.rman tag=TAG20190325T173858 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 25-MAR-19

Starting Control File and SPFILE Autobackup at 25-MAR-19
piece handle=/oradata/install/dbs/c-4027228950-20190325-02 comment=NONE
Finished Control File and SPFILE Autobackup at 25-MAR-19

RMAN>

 

 

Step 3: After the backup process is completed, the database in mount mode opens as follows.

SQL> alter database open;

Database altered.

 

You can perform all of the above operations with a shell script. To do this, you can create a file with  .sh extension by using linux and the following commands are added and this file is run in sh filename.sh from the linux command screen.

 

Yukardaki işlemlerin tamamını bir shell scripti ilede gerçekleştirebilirsiniz. Bunun için .sh uzantılı bir dosyayı linux üzerinden oluşturup içine aşağıdaki komutlar eklenir ve bu dosya linux komut ekranından sh dosyaadı.sh şeklinde çalıştırılır.

# ColdBackup Script in RMAN
rman target / << EOF
shutdown immediate
startup mount;
backup database format '/BACKUP/TESTDB_%d_%t_%s.rman';
alter database open;
EOF
exit

Mehmet Salih Deveci

I am Founder of IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress mehmetsalih.deveci@outlook.com.-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  mehmetsalih.deveci@outlook.com a mail atabilirsiniz.

Leave a Reply

Your email address will not be published. Required fields are marked *