Thursday, October 31, 2013

User Managed Backups (Hot Backup)

Online Backup (Hot Backup):
Some sites cannot shut down the database while making a backup copy of the files. The cold backup is not an available option.
So different means of backing up database must be used — the hot backup. Issue a SQL command to indicate to Oracle, on a tablespace-by-tablespace basis, that the files of the tablespace are to backed up. The users can continue to make full use of the files, including making changes to the data. Once the user has indicated that he/she wants to back up the tablespace files, he/she can use the operating system to copy those files to the desired backup destination.
The database must be running in ARCHIVELOG mode for the hot backup option.
If a data loss failure does occur, the lost database files can be restored using the hot backup and the online and offline redo logs created since the backup was done. The database is restored to the most consistent state without any loss of committed transactions.

Online Backup (Hot Backup) steps :

Steps:-
1.  Set the environmental values.
2.  Check weather Database is running Archivelog mode or not.If not running on Archive log mode keep Database in Archive log mode.
3. Put database begin backup mode.
4. Check the datafiles status.
5. Copy datafiles from PROD to TEST(Destination).
6. Make up database to the end backup.
7. Check the datafiles status
8. Switch log file once again
9. Make backup controlfile as .trc format or .txt format.
10. Copy archives files from production and development.

SET ORACLE_SID=TEST
SET ORACLE_HOME=D:\app\Administrator\product\11.2.0\dbhome_1
SET PATH=%ORACLE_HOME%\bin

 C:\>sqlplus / as sysdba

Check whether database running ARCHIVELOG MODE  mode or not.Here my Database running NOARCHIVELOG MODE.So we have to change database into ARCHIVELOG MODE .

Below are steps:

SQL> SHUT IMMEDIATE 
SQL> STARTUP MOUNT 
SQL> ALTER DATABASE ARCHIVELOG;

SQL> ALTER DATABASE OPEN;
SQL> SELECT LOG_MODE FROM V$DATABASE;



Check the locations of  Datafiles, Redolog files, Temp files & controlfiles:

SQL>select name from v$datafile;

SQL>select name from v$tempfile;
SQL>select name from v$controlfile;
SQL>select member from v$logfile;


Put the database in BEGIN BACKUP mode and check the datafiles status.

SQL> SELECT * FROM V$BACKUP;

SQL> ALTER DATABASE BEGIN BACKUP;

SQL> SELECT * FROM V$BACKUP;

When datafiles status is active then copy all the DATAFILES CONTROLEFILES , REDOLOGFILE  & TEMPFILES.

Once copied all above files then then END DATABASE BACKUP MODE & check the datafiles status.Status must be "NOT ACTIVE"












Issue the log switch query and take the conrolfile backup.Then copy all archive log files and controlfile backup.

SQL> ALETR SYSTEM SWITCH LOGFILE;

SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;











Database Hot Backup process is finished.

No comments: