Sie sind auf Seite 1von 4

Hot Backup:

For this we need to store archive logs.

Here we are doing backup for PROD databases which is stored in /u01/app/oracle/PROD.

STEP 1: LOGIN TO SQL USING PROD.


[oracle@localhost ~]$ . oraenv
SQL > startup
SQL > archive log list

STEP2: Here we need to change the archive destination.

So add a directory and change the location in next steps. (The location of the directory is
/u01/app/oracle/oradata/archivelogs)

STEP 3: If it is disabled we need to enable. For this follow the steps.

SQL> shutdown
SQL> startup mount
SQL>alter database archivelog

STEP4: Run this query and check all are in ONLINE mode.

SQL> alter database open;

SQL> Select file_name, tablespace_name, online_status from dba_data_files;

STEP 5: we need to open the database.

SQL> alter database open;

STEP 6: We need to create one directory to store all the backup files. Normally I will create this
directory in /home/oracle/backupfiles/PROD. Here I will add backupfiles/PROD.

STEP 7: Run this query.

SQL> SELECT 'ALTER TABLESPACE ' || TABLESPACE_NAME || ' BEGIN BACKUP; ' FROM
DBA_TABLESPACES WHERE TABLESPACE_NAME NOT LIKE '%TEMP%';

STEP 8: Copy and paste the result from the above query and run at sql prompt to put dbf in back up
mode.

STEP 9: Now we need to copy all the *.dbf files which are located in
/u01/app/oracle/oradata/PROD/*.dbf to /home/oracle/backups/PROD/

STEP 9: Run this query.


SQL> select 'alter tablespace ' || tablespace_name || ' end backup; ' from dba_tablespaces
where tablespace_name not like 'TEMP%';

STEP 10: Copy and paste the result from the above query and run at sql prompt.

STEP 11: Run this query.

SQL> alter system archive log current;

STEP 12: Run this query.

SQL> alter database backup controlfile to ‘/home/oracle/backups/PROD/prod_ctl.ctl’

This will copy the control file to the destination.

STEP 13: Run this query.

SQL> alter database backup controlfile to trace;

STEP14: This will create a backup control file to trace.


This will store /u01/app/oracle/PROD/admin/PROD/udump/

[oracle@localhost ~]$ ls –ltr


gives list of files in this directory.
Copy the last file to /home/oracle/backups/PROD/
[oracle@localhost ~]$ cp prod_ora_7811.trc /home/oracle/backups/PROD/prod_ctl.txt
[NOTE: Save this .trc file as .txt file.]

RECOVERY:
Scenario: When we lost all the .log files, .dbf files and .ctl files in the /u01/app/oracle/oradata/PROD/
directory.

The crucial step is Recovery after backing up the database.

STEP 1: Check this folder where we stored all of our backup files. /home/oracle/backups/PROD/

STEP2: copy prod_ctl.ctl file to /u01/app/oracle/oradata/PROD/

Cp prod_ctl.ctl /u01/app/oracle/oradata/PROD/

STEP 3: We need to change the file name entry in initPROD.ora file which is located in
/u01/app/oracle/PROD/dbs/initPROD.ora.

STEP 4: Here we have entries for control files. As we lost all these control files and we have only one
control file with the name prod_ctl.ctl, we need to change the entries here. We just need to keep only
one entry in this file.

STEP 5: Log in to SQL PLUS.

[ ]$. Oraenv
[ ]$ PROD
[ ]$ Sqlplus ‘/ as sydba”
SQL> startup nomount (not sure about this step, may be just startup or startup mount)

STEP 6: Run this command.

SQL > alter database open resetlogs;

This command will reset the logs. Here it will ask us to take the file with options “Manually”,
“AUTO” and “Cancel”

Give auto.

Then again it will ask another sequence file. May be it won’t exists. Just give cancel at that time.

STEP 7: Now run this command.

SQL> recover database using backup controlfile until cancel;

STEP 8: go and check /u01/app/oracle/oradata/archivelogs.

STEP 9: Go and check for /u01/app/oracle/oradata/PROD/ for the log files, dbf files. You need to make
sure all the files are recovered.

Das könnte Ihnen auch gefallen