10Copyright © Oracle Corporation, 2002. All rights reserved.
User-Managed Backups
10-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:
• Describe user-managed backup and recovery operations
• Discuss backup issues associated with read-only tablespaces
• Perform closed database backups
• Perform open database backups
• Back up the control file
• Perform cleanup after a failed online backup
• Use the DBVERIFY utility to detect corruption
10-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Terminology
• Whole database backup– Target database may be open or closed– Backup of all datafiles and the control file
• Partial database backups– Tablespace– Data file– Control file
• Consistent backups
• Inconsistent backups
10-4 Copyright © Oracle Corporation, 2002. All rights reserved.
10-5 Copyright © Oracle Corporation, 2002. All rights reserved.
User-Managed Backup and Recovery
• Files are backed up with operating system commands
• Backups are restored with operating system commands
• Recovery is accomplished using SQL and SQL*Plus commands
10-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Querying Views to Obtain Database File Information
V$DATAFILE
V$CONTROLFILE
V$LOGFILE
DBA_DATA_FILES
10-7 Copyright © Oracle Corporation, 2002. All rights reserved.
10-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Obtaining Database File Information
10-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Backup Methods
Physical backup
Closed database
NOARCHIVELOG mode
Closed or open database
ARCHIVELOG mode
10-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Consistent Whole Database Backup(Closed Database Backup)
Data files Control files
Passwordfile
Online or offline storage
Parameterfile
Redo logfiles
10-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Advantages of Making Consistent Whole Database Backups
• Conceptually simple
• Easy to perform
• Require little operator interaction
10-12 Copyright © Oracle Corporation, 2002. All rights reserved.
10-13 Copyright © Oracle Corporation, 2002. All rights reserved.
2
Making a Consistent Whole Database Backup
3
4
SHUTDOWN IMMEDIATE
HOST cp <files> /backup/
STARTUP OPEN
1
Control files
Passwordfile
Parameter file
Datafiles Redo log files
10-14 Copyright © Oracle Corporation, 2002. All rights reserved.
10-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database Backup
Datafiles Control files
Parameter file
Archived redolog filesPassword file
Online redolog files
10-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Advantages of MakingOpen Database Backups
• Maintains high database availability
• Can be done at a tablespace or datafile level
• Supports nonstop business operations
10-17 Copyright © Oracle Corporation, 2002. All rights reserved.
ARCHIVELOG mode
Online redo log files
Archived redo log files
ARC0
052
051
053
051052
053
LGWR
054 053052
052
051
054 053051
Open Database Backup Requirements
10-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database Backup Options
Tablespace backup
Tablespace USERS
users02.dbfusers01.dbf
Datafile backup
Tablespace USERS
users01.dbf users02.dbf
10-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Database Backup
Datafile 2144
Datafile 1143
Making a Backup of an Online Tablespace
SQL> ALTER TABLESPACE users
2> BEGIN BACKUP;
SQL> !cp /…/users01.dbf /BACKUP/users01.dbf
Database
Datafile 1
Datafile 2
Datafile 3
Controlfiles
Redo logfile 1
Redo logfile 2
145
145
145 144
145144
10-20 Copyright © Oracle Corporation, 2002. All rights reserved.
Ending the Online Tablespace Backup
SQL> ALTER TABLESPACE users
2> BEGIN BACKUP;
SQL> !cp /…/users01.dbf /BACKUP/users01.dbf
SQL> ALTER TABLESPACE users
2> END BACKUP;
Database Backup
Datafile 2144
Datafile 1143
Database
Datafile 1
Datafile 2
Datafile 3
Controlfiles
Redo logfile 1
Redo logfile 2
145
145
145 144
145145
10-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Backup Status Information
V$BACKUP
10-22 Copyright © Oracle Corporation, 2002. All rights reserved.
10-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Failure During Online Tablespace Backup
ALTER TABLESPACE users
BEGIN BACKUP;
cp /…/users01.dbf
/BACKUP/users01.dbfDatafile 3
Redo logfile 2
Control files
Redo logfile 1
Datafile 1
Database
144
145
144
144
144
Datafile 2144
Datafile 3
Redo logfile 2
Control files
Redo logfile 1
Datafile 1
Database
146
145
146
146
146
Datafile 2144
10-24 Copyright © Oracle Corporation, 2002. All rights reserved.
Ending the Online Backup
• Query V$BACKUP to check backup status
• Issue the ALTER DATABASE command to change the status and unfreeze the header:
• Or use this command in Oracle9i:
ALTER DATABASE DATAFILE ‘<filename>’ END BACKUP;
ALTER DATABASE END BACKUP;
10-25 Copyright © Oracle Corporation, 2002. All rights reserved.
10-26 Copyright © Oracle Corporation, 2002. All rights reserved.
Read-Only Tablespace Backup
ALTER TABLESPACE query_data READ ONLY;
SCN 1
SCN 2
SCN 1backup copy
1
2
SCN 2
3
4Users File 1
File 1
Users File 2
Query_Datafile 1
DBW0
10-27 Copyright © Oracle Corporation, 2002. All rights reserved.
Read-Only Tablespace Backup Issues
• Only one backup is needed after altering the tablespace to read-only.
• Resume a normal backup schedule for that tablespace after making it read-write.
• The control file must correctly identify the tablespace in read-only mode; otherwise you must recover it.
10-28 Copyright © Oracle Corporation, 2002. All rights reserved.
Backup Issues with LOGGING and NOLOGGING Options
NOLOGGINGLOGGING
All changes recorded to redo Minimal redo recorded
Fully recoverable from
last backup
Not recoverable from last
backup
No additional backup May require additional backup
10-29 Copyright © Oracle Corporation, 2002. All rights reserved.
Manual Control File Backups
• Creating a binary image
• Creating a text trace file
ALTER DATABASE BACKUP CONTROLFILE TO
'control1.bkp';
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
10-30 Copyright © Oracle Corporation, 2002. All rights reserved.
10-31 Copyright © Oracle Corporation, 2002. All rights reserved.
Backing Up the Initialization Parameter File
CREATE PFILE FROM SPFILE;
CREATE PFILE = '/backup/init.ora'
FROM SPFILE;
10-32 Copyright © Oracle Corporation, 2002. All rights reserved.
1 2
Verifying Backups Using the DBVERIFY Utility
DBVERIFY
datafiles
Online
Errorreporting
Offline
3
4
Online
10-33 Copyright © Oracle Corporation, 2002. All rights reserved.
DBVERIFY Command-Line Interface
• External command-line utility
• Used to ensure that a backup database or datafile is valid before a restore
• Can be a helpful diagnostic aid when data corruption problems are encountered
%dbv file=/ORADATA/u03/users01.dbf logfile=dbv.log
10-34 Copyright © Oracle Corporation, 2002. All rights reserved.
10-35 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Determine which files require backup and when they should be backed up
• Make user-managed backups
• Backup the control file
• Backup the server initialization parameter file
• End an online backup that did not complete due to instance failure
• Use dynamic views to determine the status of backup operations
• Use DBVERIFY to verify the backup
10-36 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 10 Overview
This practice covers the following topics:
• Performing a full offline database backup
• Performing an online backup of a tablespace datafile
• Creating a trace file of the control file
10-37 Copyright © Oracle Corporation, 2002. All rights reserved.
10-38 Copyright © Oracle Corporation, 2002. All rights reserved.