RMAN Backup Commands
Backups in RMAN
Oracle backups in RMAN are of the following type:
RMAN complete backup OR RMAN incremental backup.
These backups are of RMAN proprietary nature.
IMAGE COPY
It’s again a kind of backup. The advantage of using Image copy is it’s not in RMAN proprietary format.
Backup Format
RMAN backup is not in oracle format but in RMAN format. Oracle backup comprises of backup sets and it consists of backup pieces. Backup sets are logical entity. In oracle 9i it gets stored in a default location.
There are two type of backup sets:
Oracle backups in RMAN are of the following type:
RMAN complete backup OR RMAN incremental backup.
These backups are of RMAN proprietary nature.
IMAGE COPY
It’s again a kind of backup. The advantage of using Image copy is it’s not in RMAN proprietary format.
Backup Format
RMAN backup is not in oracle format but in RMAN format. Oracle backup comprises of backup sets and it consists of backup pieces. Backup sets are logical entity. In oracle 9i it gets stored in a default location.
There are two type of backup sets:
1. Datafile backup sets,
2. Archivelog backup sets
One more important point of data file backup sets is it do not include empty blocks. A backup set would contain many backup pieces. A single backup piece consists of physical files which are in RMAN proprietary format.
You can go to RMAN prompt by just typing rman. RMAN executable is present in ORACLE_HOME/bin location.
bash-2.05$ rman
2. Archivelog backup sets
One more important point of data file backup sets is it do not include empty blocks. A backup set would contain many backup pieces. A single backup piece consists of physical files which are in RMAN proprietary format.
You can go to RMAN prompt by just typing rman. RMAN executable is present in ORACLE_HOME/bin location.
bash-2.05$ rman
You can use target connect to connect to database. The database it will
connect to depends on the environment variable ORACLE_HOME.
RMAN> connect target
RMAN> connect target
Alternatively you can use “rman
TARGET SYS/oracle@test NOCATALOG” to connect to the RMAN of “test”
instance.
Here we will be using target database control file to store all the information required for RMAN, like backupsets and backup image information etc.
Here we will be using target database control file to store all the information required for RMAN, like backupsets and backup image information etc.
Backup Database:
RMAN> shutdown immediate
RMAN> startup mount;
RMAN> backup database;
RMAN> shutdown immediate
RMAN> startup mount;
RMAN> backup database;
Creating RMAN Catalog
You can also create a repository for RMAN to store all this information. Repository will be just another small database which can store the catalog information. Creating a catalog is a 3 step process
1) Create database which will hold the catalog. Else you can use the existing database also. All you need is to create a seperate tablespace for holding the information about RMAN catalog.
2) Create RMAN tablespace and RMAN user
SQL> create tablespace rman_tbs datafile ‘/dy/oracle/product/db10g/dbf/rman01.dbf’ size 500M EXTENT MANAGEMENT LOCAL segment SPACE MANAGEMENT AUTO;
Tablespace created
SQL> create user rman identified by rman
2 default tablespace rman_tbs
3 TEMPORARY TABLESPACE TEMPTS1
4 QUOTA UNLIMITED ON rman_tbs account unlock;
User created
After creating user, you need to grant RECOVERY_CATALOG_OWNER role to that user.
SQL> grant recovery_catalog_owner to rman;
Grant succeeded
Now Create RMAN catalog.
bash-2.05$ rman catalog rman/rman@test
connected to recovery catalog database
RMAN> create catalog
For registering the database, you need to get connected to database as well as catalog at the same time. Here is how you can do.
RMAN> connect target
RMAN-00571: =========================================================
RMAN-00569: ==============ERROR MESSAGE STACK FOLLOWS=============
RMAN-00571: =========================================================
RMAN-06004: ORACLE error from recovery catalog database:
RMAN-20001: target database not found in recovery catalog
The above error is because the database we connected to is not found in the catalog database. We can register the database in catalog.
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
Registering database will also resynch the information present in the target database control file and catalog database. Since we have taken 1 backup early, it will synchup that information with RMAN catalog. We can check the same using LIST BACKUP command at RMAN prompt.
RMAN> list backup;
RMAN Command line
Backing up the Control file and Spfile
The control file can be automatically backed up after each RMAN backup and database structure change as a way to protect the RMAN repository (when we are not using a seperate catalog for RMAN).
RMAN> configure controlfile autobackup on;
Backing up control file
RMAN> backup current controlfile;
Creating Image copy of all datafiles in database
These are the image copies and are stored in ORACLE format and not in RMAN format. Backupsets and backuppieces are stored in internal RMAN format. Hence these image copies can be used for manual restore and recovery as well.
RMAN> backup as copy database;
Creating backup sets of all datafiles in database
If you specify BACKUP AS BACKUPSET, then RMAN stores its backups in backup sets. A backup set, consisting of one or more backup pieces, contains the physical file data being backed up. This backupset is written in a format that only RMAN can access. Only RMAN can create and restore backup sets. Backup sets can be written to disk or tape, and they are the only type of backup which RMAN can use to write backups to tape.
RMAN> backup as backupset database;
Backup individual tablespace as backupdsets
RMAN> backup tablespace system, HTMLDB;
Backup individual tablespace as image copies
RMAN> backup as copy tablespace system;
Backup individual files as image copies
RMAN> backup as copy datafile ‘/dy/oracle/product/db10g/dbf/system01.dbf’;
Backup individual files as Backupsets
RMAN> backup datafile ‘/dy/oracle/product/db10g/dbf/system01.dbf’;
Backup archive logs
We can backup the archive logs according to the output of some search condition. Example we want to backup only those archive logs which starts with “ARCH_616814159_”.
RMAN> backup acrchivelog like ‘%ARCH_616814159_%’;
Copy archive logs from some time stamp.
Suppose we want to copy the archive logs of last 2 days, then we can use the following commands.
RMAN> BACKUP ARCHIVELOG from time ’sysdate-2’;
Backup all archivelog files
RMAN> Backup archivelog all;
Backup archivelog between some time.
RMAN> BACKUP ARCHIVELOG FROM TIME ‘SYSDATE-30? UNTIL TIME ‘SYSDATE-7’;
Specifying copies while backing up.
RMAN> backup copies 2 datafile ‘/dy/oracle/product/db10g/dbf/cs_tbs01.dbf’;
Remember that copies option cannot be used with image copies. It can be used only with backupsets.
Giving tags to backups
RMAN> BACKUP TAG ‘weekly_full_db_bkup’ DATABASE MAXSETSIZE 100M;
Backing up backupsets
RMAN> BACKUP BACKUPSET ALL;
Backup imagecopies
RMAN> Backup as copy backupset all;
List Imagecopies
RMAN> list copy;
List Backupsets
RMAN> list backup;
Ref: http://www.erpgreat.com
Comments
Post a Comment