Monday, December 21, 2020

find database is in BEGIN/END backup mode

 find database is in BEGIN/END backup mode


ALTER DATABASE BEGIN/END BACKUP
To take backup manually or when cloning a database using the following SQL need to be executed
which will place the database in backup mode

SQL> ALTER DATABASE BEGIN BACKUP;
Database altered.

To find if database or any tablespace is in backup mode, 
check the status column in V$BACKUP is ACTIVE

SQL> select * from v$backup;

FILE# STATUS CHANGE# TIME
———- —————— ———- ———
1 ACTIVE 14323567 01-OCT-20
2 ACTIVE 14323567 01-OCT-20
3 ACTIVE 14323567 01-OCT-20
4 ACTIVE 14323567 01-OCT-20

Here FILE# is the datafile number

now you copy the physical database files along with REDOLOGS.
REDOLOGS, will be used for database recover, incase of any pending transactions


to finish the BACKUP mode, execute below query

SQL> ALTER DATABASE END BACKUP;
Database altered.

then, check if database is in backup mode
SQL> select * from v$backup;

FILE# STATUS CHANGE# TIME
———- —————— ———- ———
1 NOT ACTIVE 14323567 01-OCT-20
2 NOT ACTIVE 14323567 01-OCT-20

If you try to shutdown of database when database is in BACKUP mode, 
you will receive the following error “ORA-01149”

SQL> shutdown immediate;
ORA-01149: cannot shutdown – file 1 has online backup set
ORA-01110: data file 1: ‘/u01/oradata/TESTDB/system_01.dbf’




If try to set the database again to BEGIN BACKUP MODE, that is already in backup mode,
you will receive the following error “ORA-01146”

SQL> alter database begin backup;
alter database begin backup
*
ERROR at line 1:
ORA-01146: cannot start online backup – file 1 is already in backup
ORA-01110: data file 1: ‘/u01/oradata/TESTDB/system_01.dbf’

In 9i to set database is backup mode, with  “ALTER DATABASE BEGIN/END BACKUP” doesn’t exists 
so it has to be done at individual tablespace level by executing below
“ALTER TABLESPACE <tablespace> BEGIN/END BACKUP”.

exp:- 
ALTER TABLESPACE SYSTEM BEGIN BACKUP;
ALTER TABLESPACE SYSTEM END BACKUP;

If try to perform incremental backup using RMAN 
it will skip backing up datafiles as datafiles are in backup
and show warning RMAN-06554

RMAN> backup incremental level 1 database;

Starting backup at 01-OCT-20
using channel ORA_DISK_1
RMAN-06554: WARNING: file 1 is in backup mode
RMAN-06554: WARNING: file 2 is in backup mode
RMAN-06554: WARNING: file 3 is in backup mode
RMAN-06554: WARNING: file 4 is in backup mode
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/oradata/TESTDB/sysaux_01.dbf
skipping datafile 00003 because it has not changed
input datafile fno=00001 name=/u01/oradata/TESTDB/system_01.dbf
skipping datafile 00001 because it has not changed
input datafile fno=00002 name=/u01/oradata/TESTDB/undo_01.dbf
skipping datafile 00002 because it has not changed
input datafile fno=00004 name=/u01/oradata/TESTDB/test_01.dbf
skipping datafile 00004 because it has not changed

channel ORA_DISK_1: backup cancelled because all files were skipped








No comments:

Post a Comment