Pages

Tuesday, July 31, 2012

How to backup a database in noarchivelog mode

This post opens a long series of posts on crash recovery scenarios and of course you cannot first restore and then recover your database without at least one backup.
In this posts I suggest also to configure the NLS_DATE_FORMAT environment variable: it's useful when you want to know from RMAN the exact date including time format a problem occurred. By default RMAN displays only the date.
My SID is ORCL, no NLS variable sets, database in NOARCHIVELOG mode.

[oracle@localhost ~]$ env|grep SID
ORACLE_SID=orcl
[oracle@localhost ~]$ env|grep NSL
[oracle@localhost ~]$ sqlplus / as sysdba
SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     580
Current log sequence           582
SQL> exit
What does it happen when I try to backup my database when it's open and in NOARCHIVELOG... ? I'm not using any recovery catalog for these examples as you can see.
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Jul 15 05:36:18 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> backup database;

Starting backup at 15-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=32 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/15/2012 05:36:42
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 15-JUL-12
channel ORA_DISK_1: finished piece 1 at 15-JUL-12
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_ncsnf_TAG20120715T053641_805gbvhz_.bkp tag=TAG20120715T053641 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/15/2012 05:36:42
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
RMAN> exit

Recovery Manager complete.
As you can easily read from the RMAN log put on screen you... "ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode". Note also that some logs (Starting backup at 15-JUL-12) write the date and it doesn't show any time information. So let's first set the NLS_DATE_FORMAT environment variable to the right value
[oracle@localhost ~]$ echo "export NLS_DATE_FORMAT='DD-MM-RRRR HH24:MI:SS'" >> .bash_profile 
[oracle@localhost ~]$ export NLS_DATE_FORMAT='DD-MM-RRRR HH24:MI:SS'

To backup a database in NOARCHIVELOG mode you have to shutdown it first, open in mount mode and only then you can start your backup process.
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Jul 15 05:43:30 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> shutdown immediate;

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                352324280 bytes
Database Buffers              96468992 bytes
Redo Buffers                   6008832 bytes

RMAN> backup database;

Starting backup at 15-07-2012 05:47:44
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf
input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.dbf
channel ORA_DISK_1: starting piece 1 at 15-07-2012 05:47:46
channel ORA_DISK_1: finished piece 1 at 15-07-2012 05:50:43
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_nnndf_TAG20120715T054745_805gzldn_.bkp tag=TAG20120715T054745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:57
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 15-07-2012 05:50:45
channel ORA_DISK_1: finished piece 1 at 15-07-2012 05:50:46
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_ncsnf_TAG20120715T054745_805h55ol_.bkp tag=TAG20120715T054745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-07-2012 05:50:46

How can I see my backup on RMAN ? Use just the following command:
RMAN> list backup;

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
1       Full    9.36M      DISK        00:00:02     15-07-2012 05:32:28
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20120715T053225
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_ncsnf_TAG20120715T053225_805g2vpk_.bkp
  SPFILE Included: Modification time: 15-07-2012 05:24:54
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 13564407     Ckp time: 15-07-2012 05:32:25

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
2       Full    9.36M      DISK        00:00:01     15-07-2012 05:36:43
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20120715T053641
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_ncsnf_TAG20120715T053641_805gbvhz_.bkp
  SPFILE Included: Modification time: 15-07-2012 05:24:54
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 13564668     Ckp time: 15-07-2012 05:36:42

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    1.90G      DISK        00:02:50     15-07-2012 05:50:35
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20120715T054745
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_nnndf_TAG20120715T054745_805gzldn_.bkp
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 13565488   15-07-2012 05:44:01 /home/oracle/app/oracle/oradata/orcl/system01.dbf
  2       Full 13565488   15-07-2012 05:44:01 /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
  3       Full 13565488   15-07-2012 05:44:01 /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
  4       Full 13565488   15-07-2012 05:44:01 /home/oracle/app/oracle/oradata/orcl/users01.dbf
  5       Full 13565488   15-07-2012 05:44:01 /home/oracle/app/oracle/oradata/orcl/example01.dbf
  6       Full 13565488   15-07-2012 05:44:01 /home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
4       Full    9.36M      DISK        00:00:02     15-07-2012 05:50:46
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20120715T054745
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_07_15/o1_mf_ncsnf_TAG20120715T054745_805h55ol_.bkp
  SPFILE Included: Modification time: 15-07-2012 05:44:26
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 13565488     Ckp time: 15-07-2012 05:44:01

Have a look at the time when the backup is finished and the time information provided by the "list backup" command in RMAN... So we have a first backup... That's all