RMAN tablespace and datafile backup Script for Oracle Database

Following scripts will backup the tablespace and datafile present in Oracle Database.

First you need to list the schema with RMAN Report:


RMAN> report schema;

Report of database schema for database with db_unique_name XE

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    910      SYSTEM               YES     C:\ORACLE\ORADATA\XE\SYSTEM01.DBF
3    660      SYSAUX               NO      C:\ORACLE\ORADATA\XE\SYSAUX01.DBF
4    65       UNDOTBS1             YES     C:\ORACLE\ORADATA\XE\UNDOTBS01.DBF
5    250      PDB$SEED:SYSTEM      NO      C:\ORACLE\ORADATA\XE\PDBSEED\SYSTEM01.DBF
6    370      PDB$SEED:SYSAUX      NO      C:\ORACLE\ORADATA\XE\PDBSEED\SYSAUX01.DBF
7    5        USERS                NO      C:\ORACLE\ORADATA\XE\USERS01.DBF
8    100      PDB$SEED:UNDOTBS1    NO      C:\ORACLE\ORADATA\XE\PDBSEED\UNDOTBS01.DBF
13   260      PDB1:SYSTEM          NO      C:\ORACLE\ORADATA\XE\PDB1\SYSTEM01.DBF
14   400      PDB1:SYSAUX          NO      C:\ORACLE\ORADATA\XE\PDB1\SYSAUX01.DBF
15   100      PDB1:UNDOTBS1        NO      C:\ORACLE\ORADATA\XE\PDB1\UNDOTBS01.DBF
16   5        PDB1:USERS           NO      C:\ORACLE\ORADATA\XE\PDB1\USERS01.DBF

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    129      TEMP                 32767       C:\ORACLE\ORADATA\XE\TEMP01.DBF
2    62       PDB$SEED:TEMP        32767       C:\ORACLE\ORADATA\XE\PDBSEED\TEMP012019-09-18_15-38-03-475-PM.DBF
4    62       PDB1:TEMP            62          C:\ORACLE\ORADATA\XE\PDB1\TEMP012019-09-18_15-38-03-475-PM.DBF

RMAN Backup script for the tablespace

run
{ 
allocate channel c1 type disk format 'C:\archive\backup\%I-%Y%M%D-%U' maxpiecesize 5G;
allocate channel c2 type disk format 'C:\archive\backup\%I-%Y%M%D-%U' maxpiecesize 5G;
backup tablespace PDB1:USERS, USERS;
release channel c1 ;
release channel c2 ;
}

RMAN backup script for the datafiles

run
{ 
allocate channel c1 type disk format 'C:\archive\backup\%I-%Y%M%D-%U' maxpiecesize 5G;
allocate channel c2 type disk format 'C:\archive\backup\%I-%Y%M%D-%U' maxpiecesize 5G;
backup datafile 7,16;
release channel c1 ;
release channel c2 ;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.