How to take backup of the entire database? i.e database files and the control files
RMAN won't take backup of log files.
RMAN>backup database;
If you want to take a complete backup as a compressed backup and also specify the location with control file, then use the following syntax
RMAN> backup as compressed backupset format 'Desired location' include current controlfile;
It will backup entire database files along with control file.
How to take backup of the entire tablespace?
RMAN>backup tablespace tablespacename;
eg: RMAN>backup tablespace SYSTEM;
It will take backup of all data files belong to SYSTEM tablespace.
Assume system contains 3 datafiles it will take all dbf files
How to take backup of a particular datafile?
RMAN>backup datafile '/home/sales/userdata.dbf';
This will take backup of only specified file.
How to take backup of control file using RMAN?
sql>conn /as sysdba
sql>select cotnrolfile_type from v$database;
CURRENT
--------------------------------------------------
RMAN>backup current cotnrolfile;
Note: if the target database is running using spfile.
Then only we can take spfile backup.
RMAN>backup spfile;
How to take backup of archive logs?
RMAN>backup archivelog all;
How to take the backup of database plus archive log files?
RMAN>backup database plus archivelog;
This will take datafiles, controlfiles and arhivelogs.
Practical demo
----------------
RMAN>connect catalog rman/rman@to_sales;
RMAN>connect target sys/prd@to_sales;
RMAN>backup database;
------------------------------------------------------------------
Note: cp command will simply copy whether the block is corrupted
or not. RMAN won't take the backup in the corrupted blocks.
------------------------------------------------------------------
go to serverside and check it.
]$cd $ORACLE_HOME/dbs
dbs]$ls
Here we can find backup files.
------------------------------------------------------------
Take backup of tablespace
------------------------
RMAN>backup tablespace system;
RMAN>report schema;
Take backup of datafile
-----------------------
rman>backup datafile 'path';
rman>list backup;
(we can check whether the backups are available or not)
Detailed information
rman>list backup summary;
How to delete rman backups?
RMAN>list backup summary;
RMAN>delete backupset backupsetkey;
eg: RMAN>delete backupset 51;
(enter yes/no)?yes
You can check
RMAN>list backup summary;
It is displaying all
How to delete all?
If we don't want confirmation
RMAN>delete noprompt backupset backupsetno;
eg: RMAN>delete noprompt backupset 52;
RMAN>delte backup;
The above command will delete everything.
RMAN>list backup summary;
20090907
--------------------------------------------------------------
RMAN>backup database;
RMAN>list backup summary;
RMAN>delete force backup;
RMAN>list backup;
--------------------------------------------------------
How to take backup at desired location?
With the help of format command we can keep the backup files in particular location.
DEMO
----
On the target (server side) go to opt directory
opt]$mkdir backup
login as root user and give the permissions
opt]$ls
backup
These format specifiers are used with format command
%d - It indicates database name
%u - 8 character unique id
%T --Current system date
backupfilename_%d_%T20090907
RMAN>backup tablespace userdata format '/opt/backup/rman_%d_%T';
------------------------------------------------------
Take complete backup for recovery purposes
-------------------------------------------
RMAN> backup database;
Starting backup at 29-AUG-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/sales/system.dbf
input datafile fno=00002 name=/home/sales/undosales.dbf
input datafile fno=00003 name=/home/sales/sysaux.dbf
input datafile fno=00004 name=/home/sales/userdata.dbf
channel ORA_DISK_1: starting piece 1 at 29-AUG-09
channel ORA_DISK_1: finished piece 1 at 29-AUG-09
piece handle=/home/oracle/product/10.2.0/db_1/dbs/11knu0kf_1_1 tag=TAG20090829T1 75942 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 29-AUG-09
channel ORA_DISK_1: finished piece 1 at 29-AUG-09
piece handle=/home/oracle/product/10.2.0/db_1/dbs/12knu0km_1_1 tag=TAG20090829T1 75942 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-AUG-09
----------------------------------------RMAN>