Main

Backup & recovery Archives

May 18, 2007

Rman Backup scripts

Backup a complete database:

(If the target database is in archive mode, this can be done while the database is open)





RMAN>


run {                                      

# backup complete database to disk            

allocate channel c1 type disk;                

backup full                                   

tag full_db                                   

format '/usr1/ora817/test/rman/db_d.dmp'

(database);                                   

release channel c1;                           

}                                             



You can create a script and use it multiple times, so each time you
don't need to type the above script. Just make sure to drop the old
backup files.



RMAN>

create script full_db_backup {            

allocate channel c1 type disk;            

backup full database                      

format '/usr1/ora817/test/rman/db_%d.dmp';

release channel c1;                       

}                                         



This is how you run the script:



RMAN>

run { execute script full_backup ;}    





Archive logs too can be backed up along with the database in one script:



RMAN>

create script full_db_arc_backup {            

allocate channel c1 type disk;                                            

backup full database                                                      

format '/usr1/ora817/test/rman/db_%d.dmp';                                

release channel c1;                                                      

allocate channel c2 type disk format '/usr1/ora817/test/rman/arc_%d.dmp';

backup (archivelog all delete input);                                     

release channel c2;                                                       

}                                                                         



- '%d' puts database name in the backup file name.

- 'all delete input' in above script deletes all the archive logs once the backup is   

   complete, thus frees up the space.



RMAN>

run { execute script full_db_arc_backup ;}    


June 11, 2007

Recovery Scenarios Part-2

Part 2 for the recovery scenarios

B) Lost control File or Media Failure:
      (Disk lost with all the files w/o SYSTEM tablespace)

SVRMGRL> shutdown abort;
SVRMGRL> STARTUP NOMOUNT;

RMAN>
run {
allocate channel c1 type disk;
restore controlfile to '/usr1/ora817/test/dbs/control01.ctl';
replicate controlfile from '/usr1/ora817/test/dbs/control01.ctl';
restore database;
sql "alter database mount";
recover database;
sql "alter database open resetlogs";
release channel c1;
}
RMAN> Reset database

(C) Table recovery: (Incomplete recovery)

This
happens when some one drops table by mistake, and by the time he/she
informs the DBA, other people are still working on the database. So the
DBA has to recover the database until time when the table was dropped.
That causes other people to re-work from that point onwards, and hence
it is an "Incomplete recovery"

When something like this happens, try to find out the exact time of accident.

SVRMGRL> shutdown immediate;
SVRMGRL> STARTUP MOUNT;

RMAN>
run {                                 
allocate channel c1 type disk;           
set until time "to_date('2004-01-16:13:17:00','YYYY-MM-DD:HH24:MI:SS')";  
restore database;                        
recover database;                        
sql "alter database open resetlogs";     
}  
RMAN> Reset database
 
 

(D) If both the ACTIVE redolog files are gone:

SVRMGRL> startup nomount;

RMAN>
run {
allocate channel c1 type disk;
set until logseq=7 thread=1;
restore controlfile to '/usr1/ora817/test/dbs/control01.ctl';
replicate controlfile from '/usr1/ora817/test/dbs/control01.ctl';
restore database;
sql "alter database mount";
recover database;
sql "alter database open resetlogs";
release channel c1;
}

If for some reason this attempt fails,

SVRMGRL> alter database mount;  (equivalent of startup mount;)
SVRMGRL> alter database drop logfile group 2;  (optional)
SVRMGRL> recover database using backup controlfile until cancel;  

(Recover to the point till you have good archivelogs, and then Type CANCEL at the prompt)
 
SVRMGRL> alter database open resetlogs;

RMAN> Reset database

Run the following script to find out the status of backup process:

alter session set NLS_DATE_FORMAT = 'MM/DD/YY (HH:MIAM)';

col start_time format a20 heading "Backup of this|Database started at"
col a format 999.99 heading "% Complete|so far"
col b format a20 heading "Time taken so far|for this backup"

select start_time,round(sofar/totalwork*100,2) a ,
mod(floor((sysdate-start_time)*24),24)||'
Hrs and
'||floor(((mod(round((sysdate-start_time)*24,2),24))-(mod(floor((sysdate-start_time)*24),24)))*60)||'
Mins' as b
from v$session_longops
 where substr(opname,1,4)='RMAN'
 and (round(sofar/totalwork*100,2))<100
 and (round(sofar/totalwork*100,2))>0
 and totalwork !=0;
-- -----------------------------------------

July 11, 2007

Backing Up and Recovering Voting Disks

Backing Up and Recovering Voting Disks

What is a voting disk & why its needed ?
The voting disk records node membership information. A node must be
able to access more than half of the voting disks at any time.

For example, if you have seven voting disks configured, then a node must
be able to access at least four of the voting disks at any time. If a
node cannot access the minimum required number of voting disks it is evicted, or removed, from the cluster.

Backing Up Voting Disks

When to backup voting disk ?

  1.       After installation
  2.       After adding nodes to or deleting nodes from the cluster
  3.       After performing voting disk add or delete operations

To make a backup copy of the voting disk, use the Linux dd command. Perform this operation on every voting disk as needed where voting_disk_name is the name of the active voting disk and backup_file_name is the name of the file to which you want to back up the voting disk contents:
dd if=voting_disk_name of=backup_file_name

If your voting disk is stored on a raw device, use the device name in place of voting_disk_name. For example:
dd if=/dev/sdd1 of=/tmp/voting.dmp

Note : When you use the dd command for making backups of the voting disk, the backup can be performed while the Cluster Ready Services (CRS) process is active; you do not need to stop the crsd.bin process before taking a backup of the voting disk.

Recovering Voting Disks

If a voting disk is damaged, and no longer usable by Oracle Clusterware, you can recover the voting disk if you have a backup file.

dd if=backup_file_name of=voting_disk_name

About Backup & recovery

This page contains an archive of all entries posted to Pankaj Chandiramani's Blog in the Backup & recovery category. They are listed from oldest to newest.

ASM is the previous category.

Data Guard is the next category.

Many more can be found on the main index page or by looking through the archives.

Top Tags

Powered by
Movable Type and Oracle