Oracle 11g database RMAN:
How to backup a database using RMAN command?
I use the following Oracle 11g RMAN commands daily and I like you know
Assuming that your database is in flashback mode and you have registered
your database in the RMAN recovery catalog.
To connect to rman:
rman target sys/pass@mydb catalog sys/pass@mycatalog
If you are not using catalog just ignore the catalog login
OR - you can connect to your target and catalog separately when you are
in the Oracle RMAN.
connect catalog user/password@mycatalog
Once you connect to target, you can backup.
To back up the whole database:
RMAN> backup database;
If you want your backup to be in
directory with specific name format use the following.
RMAN> BACKUP DATABASE FORMAT "/backup/oracle/%d-%T-%s-%P";
Notice that the formatting of this information varies by platform.
The name of the database.
The current day of the month (in format DD)
The month (format MM)
The year (YYYY)
The year, month, and day (YYYYMMDD)
Combination of DBID, day, month, year, and sequence
The piece number within the backup set.
The backup set number.
The backup set time stamp, which is a 4-byte value
You can backup archivelogs and control files.
RMAN> backup archivelog all;
RMAN> backup controlfile;
You can also, backup all and delete the archivelogs after backup. I love
this. Does it all.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
Some very basic and simple things you must know:
If you are using catalog, make sure that your database is registered.
To register/unregister a database:
RMAN> REGISTER DATABASE;
RMAN> UNREGISTER DATABASE;
Use the SHOW PARAMEER and the V$RECOVERY_FILE_DEST,
V$RECOVERY_AREA_USAGE dynamic dictionaries to discover the status and
size of your recovery file.
Example: show parameter flash/show parameter recovery, etc.
SQL> set linesize 1000
SQL> set pagesize 1000
SQL> show parameter recovery
SQL> show parameter flash
SQL> select * from v$recovery_area_size;
Troubleshooting to backup using the Oracle RMAN:
Sometimes you deliberately or accidently had deleted your archivelogs
not using the DELETE INPUT option in the BACKUP statement. If you did
that your backup will fail and you are not able to do any backup. In
order to fix this problem, you need to do the following.
RMAN> CROSSCHECK archivelog all;
RMAN> CROSSCHECK BACKUP;
How to clear your flashback area:
You can also do cleaning: (CLEAR FLASHBACK)
RMAN> DELETE BACKUP OF DATABASE;
RMAN> DELETE BACKUP OF ARCHIVELOG ALL;
RMAN> DELETE BACKUP OF CONTROLFILE;
Recover a table:
Assuming that your database is in flashback recovery mode, you can
flashback the whole database back to specific time. First you need to
shutdown the database and start it in the mount mode.
SQL> shutdown immediate;
SQL> startup mount;
SQL> FLASHBACK database
TO TIMESTAMP SYSTIMESTAMP - INTEVAL xxx MINUTES;
-For a table ...
SQL> FLASHBACK TABLE emp TO TIMESTAMP SYSTIMESTAMP - INTEVAL xxx