Showing posts with label Backup and Recovery. Show all posts
Showing posts with label Backup and Recovery. Show all posts

Wednesday, September 3, 2025

RMAN Shell Script to backup to the disk

#!/bin/bash

BACKUP_DATE=$(date +%Y%m%d_%H%M%S)

BACKUP_DIR="/oracle/FRA/FULL_BKP_20250826"

ORACLE_HOME=/oracle/app/oracle/product/19.0.0/dbhome_1

ORACLE_SID=MYDB

export ORACLE_HOME ORACLE_SID RMAN_DIR PATH=$ORACLE_HOME/bin:$PATH


rman target / log=${BACKUP_DIR}/backup_${BACKUP_DATE}.log <<EOF

RUN {

  ALLOCATE CHANNEL C1 TYPE DISK FORMAT '${BACKUP_DIR}/%U';

  CONFIGURE COMPRESSION ALGORITHM 'MEDIUM';

  BACKUP TABLESPACE USERS FORMAT '${BACKUP_DIR}/tablespace_%U.bkp';

  BACKUP CURRENT CONTROLFILE FORMAT '${BACKUP_DIR}/control_before_patch_%U.ctl';

  #BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '${BACKUP_DIR}/db_full__before_patch_%U.bkp';

  #BACKUP ARCHIVELOG ALL FORMAT '${BACKUP_DIR}/archive__before_patch_%U.bkp';

  RELEASE CHANNEL C1;

}

EOF


Monday, May 13, 2013

Script to restore archive logs



#!/usr/bin/ksh
date

export ORACLE_SID=MYDBSTB
export NLS_LANG=american
export NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'
export ORACLE_HOME=/ora/fs0000/app/oracle/product/9.2.0.3
rman target / catalog mycat/mycatpwd@catdb <<eOfScript

spool log to '/ora/fs0000/app/oracle/admin/MYDBSTB/logbook/20130511.RestoreArchives.Alex/restore_archlogs.log' ;

run {
allocate channel t1 type 'SBT_TAPE' PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
allocate channel t2 type 'SBT_TAPE' PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
allocate channel t3 type 'SBT_TAPE' PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
send 'NB_ORA_SERV=<nbserver_comp>, NB_ORA_CLIENT=<nbclient_comp>';
#restore archivelog from time 'Apr 26 2013 04:55:06' until time 'Apr 28 2013 08:52:00';
restore archivelog from logseq 4095908 until logseq 4095958 thread 1;
release channel t1;
release channel t2;
release channel t3;
}
exit
eOfScript
date
exit

Identify which tapes needed for recovery


Look at media column to identify the tapes

col handle for a40
col media for a30
 SELECT   piece#, tag, media, handle,
    TO_CHAR (start_time, 'DD-MON-YYYY HH24:MI:SS') AS start_time,
    TO_CHAR (completion_time, 'DD-MON-YYYY HH24:MI:SS') AS completion_time
   FROM rc_backup_piece
    WHERE start_time >= TO_DATE ('14-MAR-2013 00:00:00', 'dd-mon-yyyy HH24:MI:SS')
    AND completion_time < TO_DATE ('16-MAR-2013 00:00:00', 'dd-mon-yyyy HH24:MI:SS')
    ORDER BY 1;

Thursday, December 24, 2009

How To Rename A Database Target in Grid Control


The information in this document applies to: 
Enterprise Manager Grid Control - Version: 10.1.0.2
Information in this document applies to any platform.
Goal
This document will explain how you can change the defined name for a database target in Grid Control.


Fix
To change the name of the database target, the actual database must be dropped from the targets window and then rediscovered and reconfigured.

To do this:
  1. From the Home page window, select the Databases tab.
  2. In the Databases window, select the database that you wish to rename.
  3. Select Remove.
  4. After the database has been removed, click on the Add button
  5. Enter the host you wish to discover and click on continue.
  6. The list of databases now appear, select the database that was previously removed and select click in the Configure box.
  7. In here is where you can set the target name to a different name if desired and continue.
  8. It will then display the new name that you have configured, at this point, select OK and it will update the database target name.

RAC on ASM replication using an NFS mounted File System


One of the RAC environments I’m working with is a very critical production database, there are several development, test and training clones of it, and from time to time a new clone needs to be created.


The main backup strategy we are using is based on EMC snapshots, so we can easily create clones from snapshots.


Still sometimes you get not standard requirements, or find circumstances that require creative solutions.


How to restore schema in 10g using DataPump.


Introduction
There are the steps we are going to do:
  1. Create schema ALEX.
  2. Export schema TH_NEW using DataPump and import into ALEX schema.
  3. Export schema ALEX using DataPump.
  4. Make several changes in schema ALEX.
  5. Restore schema ALEX using DataPump Import Utility.
     

How to perform recovery on a database that is not in archive log mode, using the redo logs


In some situations, databases that have a small number of concurrent transactionscan be recovered using the online archive logs.

Example Case:
  • A file system that contains a database is backed up every day at 10:00
  • The database is not in archive log mode
  • Redo logs are sitting on a separate disk and are not backed up
  • Log switches occur once or twice a day and there are three groups
  • At 13:30 the database was brought down and by mistake a datafile was damaged
  • The datafiles are recovered from the backup done at 10:00

Parallel Rollback may hang database, Parallel query servers get 100% cpu

Problem Description
——————-

Sometimes Parallel Rollback of Large Transaction may become very slow. After killing a large running transaction (either by killing the shadow process or aborting the database) then database seems to hang, or smon and parallel queryservers taking all the available cpu.  After killing shadow process or aborting the database the v$transaction entry is lost, so you cannot estimate by
examining v$transaction.used_ublk how the rollback procedure proceeds.

Database Hangs Because SMON is taking 100% CPU doing transaction recovery


Applies to:
Oracle Server - Enterprise Edition - Version: 8.1.7 to 10.2
Information in this document applies to any platform.

Goal
After killing a large running transaction, either by killing the process or aborting the database, the database may appear to hang
and/or the SMON background process is taking all the available cpu. Basically SMON is in the progress of rolling back this terminated
large transaction, which can be time consuming. As a result of this users often try to restart the database, but because a shutdown
immediate will hang, the database is often aborted. Please note that stopping the database will actually make things worse and will not ecrease the amount of work SMON needs to perfom to complete the rollback.

The message ‘Waiting for smon to disable tx recovery’ will posted in the alert log as well.

How to copy DBs between two servers using Hot Backup

On the source server:
  1. Change the environment:

    setenv ORACLE_SID HOT

  2. Connect as user SYS to SQL*Plus:

  1. oracle@ayevenunxmavtst1:/database_jery>sqlplus 'sys as sysdba'

How to un-register database from RMAN repository

oracle@myunxsrv:/oracle>sqlplus rmanadmin/rmanadmin@rmandb

SQL> select * from rc_database;

   DB_KEY  DBINC_KEY       DBID NAME     RESETLOGS_CHANGE# RESETLOGS
   ———————————————————————————-
     82740      82741 4068072203 DB1            1833108725 15-NOV-05

    109899     109900 3178819647 MYDB           1839426791 23-NOV-05

    506581     506582 3053438738 ORAGRID            157703 01-MAY-07

         1          2 1637292221 EMULE                   1 10-JAN-05

12 rows selected.

SQL> exec dbms_rcvcat.unregisterdatabase( 1, 1637292221 );

PL/SQL procedure successfully completed.