Monday, 15 January 2007

Recovering after SHUTDOWN ABORT, or CRASH during OS hot-backup

What to do if the hotbackup database crashes during the hotbackup?
When this happens the tablespaces are going to be in an inconsistent state, the database will not OPEN and a STARTUP will give an error similar to:
ORA-01113: file 12 needs media recoveryORA-01110: data file 12: ‘/oracle/dbs/tbs_41.f’

In this situation what you can do is limited to 2 things:

1. Recover the database.
2. Mount the database, then run ALTER DATABASE END BACKUP


1. Recover the database.

Before you use the following quick steps make sure you read the link as well, provided at the bottom of this page. Also use this step when you are not sure if a RESTORE was made after the crash, perhaps by the backup operator!? If there was a restore then the RECOVER command will bring the database up to date as well.

1. Mount your database. For example, enter:

SQL> STARTUP MOUNT

2. Recover your database as normal. For example, enter:

SQL> RECOVER DATABASE

3. Use the V$BACKUP view to confirm that there are no active datafiles:

SQL> SELECT * FROM V$BACKUP WHERE STATUS = 'ACTIVE';

FILE# STATUS CHANGE# TIME
———- —————— ———- ———

0 rows selected.

4. Open the database for business.

SQL> ALTER DATABASE OPEN;


2. Mount the database, then run ALTER DATABASE END BACKUP.

When you get the above STARTUP error message probably the database will be in MOUNT state already. You can choose to carry one with the commands below immediately after the message or choose to do a SHUTDOWN ABORT and then STARTUP MOUNT. To take tablespaces out of backup mode simultaneously, the database must be in MOUNT state:

1. Mount but do not open the database. For example, enter:

SQL> STARTUP MOUNT

2. If performing this procedure manually (that is, not as part of a crash recovery script), query the V$BACKUP view to list the datafiles of the tablespaces that were being backed up before the database was restarted:

SQL> SELECT * FROM V$BACKUP WHERE STATUS = 'ACTIVE';FILE# STATUS CHANGE# TIME
———- —————— ———- ———
12 ACTIVE 20863 25-NOV-00
13 ACTIVE 20863 25-NOV-00
20 ACTIVE 20863 25-NOV-00
3 rows selected.

3. Issue the ALTER DATABASE END BACKUP statement to take all datafiles currently in backup mode out of backup mode. For example, enter:

SQL> ALTER DATABASE END BACKUP;

You can use this statement ONLY and ONLY when the database is mounted but not open. If the database is open, use ALTER TABLESPACE … END BACKUP or ALTER DATABASE DATAFILE … END BACKUP for each affected tablespace or datafile and that is what happens during the hot backup.

4. Open the database for business.

SQL> ALTER DATABASE OPEN;

After this you should take a new backup of the db immediately!
Source and further reading at this Oracle Link:http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96572/osbackups.htm#9817

No comments: