No great genius has ever existed without some touch of madness.

Monday 14 November 2011

Basic explanation of COLD BACKUP and HOT BACKUP


A database is in CONSISTENT STATE when it shut down normally .
If database ARCHIVING is not enabled(NOARCHIVELOG) you must take a CONSISTENT backup

A database is in INCONSISTENT STATE when it is open and there are ongoing transactions AND it is shutdown abnormally .
If database ARCHIVING is enabled(NOARCHIVELOG) you take an INCONSISTENT backup.













------------A HOT BACKUP is one that is taken when database is OPEN and is possible only if the database is in ARCHIVELOG mode.
(PROBLEM)---HOT BACKUPS are performed at TABLESPACE level only.

EXAMPLE
SQL>ALTER TABLESPACE USERS BEGIN backup;

SQL> host cp /u01/app/oracle/oradata/orcl/users01.db /home/oracle/hotbackup
SQL> host cp /u01/app/oracle/oradata/orcl/users02.db  /home/oracle/hotbackup

SQL>ALTER TABLESPACE USERS END BACKUP;

---Next, force a log switch so Oracle will archive the current redo log file.(for redo generated during the backup)
          SQL>Alter system switch logfile;

Backup the CONTROL FILE  using the following command:
alter database backup controlfile to 'file_name';













-------------A COLD BACKUP is taken when database is CLOSED and is possible in both NOARCHIVELOG and ARCHIVELOG mode.

a))) To take a COLD BACKUP,database must be shutdown in a consistent manner.....by issuing one of        the following commands:
1)shutdown normal
2)shutdown transactional

If the database is shutdown with the IMMEDIATE or ABORT option, it should be restarted in RESTRICT mode and then shutdown with the NORMAL option.

b))) DETERMINE LOCATIONS (while database is startup)
       SQL> select value from v$parameter where name = 'spfile'; 
       SQL> select name from v$controlfile;
       SQL> select name from v$datafile;


After shutting down the database,copy the DATAFILES,CONTROL FILES,REDO LOG FILES, PASSWORD FILE and PARAMETER FILE of the database to your backup device using os 'copy' command.
     

c))) start up the database..