Simple Offline oracle database backup using RMAN
SQL>Shutdown immediate;
SQL>Startup mount;
$ rman target orcl (orcl is the SID or connect string alias)
Take a full database backup and save it on /home/oracle
RMAN> run {
allocate channel t1 type disk;
backup database format '/home/oracle/%d_%u_%s';
release channel t1;
}
if you are running Oracle 10g, you can use the compressed clause
RMAN> run {
allocate channel t1 type disk;
backup as compressed backupset database format
'/home/oracle/%d_%u_%s';
release channel t1;
}
It will give you a 5 time decrease in space
To find out information about your latest backup operation
RMAN> list backupset
2> ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 2.16G DISK 00:05:50 17-MAR-08
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20080317T112227
Piece Name: D:\BACKUPS\ORCL_02JBG37K_2
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 5068690 17-MAR-08 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
2 Full 5068690 17-MAR-08 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
3 Full 5068690 17-MAR-08 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
4 Full 5068690 17-MAR-08 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
5 Full 5068690 17-MAR-08 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
6 Full 5068690 17-MAR-08 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\FLOW_1.DBF
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 6.80M DISK 00:00:05 17-MAR-08
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20080317T112227
Piece Name: D:\BACKUPS\ORCL_03JBG3IO_3
Control File Included: Ckp SCN: 5068690 Ckp time: 17-MAR-08
SPFILE Included: Modification time: 17-MAR-08
You can validate the backupset to make sure that the physical backup that you
made is not corrupted
RMAN> validate backupset 1
2> ;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: reading from backup piece D:\BACKUPS\ORCL_02JBG37K_2
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUPS\ORCL_02JBG37K_2 tag=TAG20080317T112227
channel ORA_DISK_1: validation complete, elapsed time: 00:06:45
You can also backup the entire database using default setting as follows
# Whole database and archivelogs.
RMAN>BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
TO RECOVER
$rman target orcl --- SID is orcl in this case, use your SID
RMAN> startup nomount; -- assuming that the spfile exists
RMAN>restore controlfile from autobackup; -- assuming the controlfile are lost
RMAN> Alter database mount;
RMAN> restore database; -
-- you may need to reset the logs
RMAN> Alter database open reset logs;