Oracle® Database Backup and Recovery Quick Start Guide 10g Release 2 (10.2) Part Number B14193-02 |
|
|
View PDF |
Use the RMAN BACKUP
command to back up files. You will usually configure default devices and channels in advance; BACKUP
backs up your data to the configured default device and channels for the type of backup requested.
If you specify BACKUP
AS
COPY
, then RMAN copies the files as image copies, bit-for-bit copies of database files created on disk. These are identical to copies of the same files that you can create with operating system commands like cp
on Linux or COPY
on Windows, but by using BACKUP
AS
COPY
they are recorded in the RMAN repository and RMAN can use them in restore operations. Image copies cannot be created on tape.
This command creates image copy backups of all datafiles in the database:
RMAN> BACKUP AS COPY DATABASE;
If you specify BACKUP
AS
BACKUPSET
, then RMAN stores its backups in backup sets. A backup set consists of one or more backup pieces, physical files containing the data, written in a format that only RMAN can access. Only RMAN can create and restore backup sets. Backup sets can be written to disk or tape, and they are the only that RMAN can use to write backups to tape.
The following command creates a backup of the database and archived logs on tape, in backup set format, using the configured channels:
RMAN> BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG;
Note: Backing up datafiles as backup sets on disk can save disk space and time because RMAN can skip backing up some unused datafile blocks. Backup sets, once written on disk, can be moved to tape with theBACKUP BACKUPSET command. See the description of unused block compression in Oracle Database Backup and Recovery Reference for details. |
Backing Up Individual Files
You can back up individual tablespaces, datafiles and control files, server parameter files, and backup sets with various options, as in these examples:
RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN 'SYSDATE-31' AND 'SYSDATE-7'; RMAN> BACKUP TABLESPACE system, users, tools; RMAN> BACKUP AS BACKUPSET DATAFILE 'ORACLE_HOME/oradata/trgt/users01.dbf', 'ORACLE_HOME/oradata/trgt/tools01.dbf'; RMAN> BACKUP DATAFILE 1,3,5; RMAN> BACKUP CURRENT CONTROLFILE TO '/backup/curr_cf.copy'; RMAN> BACKUP SPFILE; RMAN> BACKUP BACKUPSET ALL;
Backup Options
Here are some often-used BACKUP
command options:
Parameter | Example | Explanation |
---|---|---|
FORMAT |
FORMAT '/tmp/%U' |
Specifies a location and name for backup pieces and copies. You must use substitution variables to generate unique filenames. |
TAG |
TAG 'monday_bak' |
Specifies a user-defined string as a label for the backup. If you do not specify a tag, then RMAN assigns a default tag with the date and time. |
The following BACKUP
commands illustrate these options:
RMAN> BACKUP FORMAT='AL_%d/%t/%s/%p' ARCHIVELOG LIKE '%arc_dest%'; RMAN> BACKUP TAG 'weekly_full_db_bkup' DATABASE MAXSETSIZE 10M; RMAN> BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;
Incremental Backups
If you specify BACKUP
INCREMENTAL
, RMAN will create incremental backups of your database. Incremental backups capture on a block-by-block basis changes in your database since a previous incremental backup. The starting point for an incremental backup strategy is a level 0 incremental backup, which backs up all blocks in the database. Level 1 incremental backups, taken at regular intervals, contain only changed blocks since a previous incremental backup. These can be cumulative (including all blocks changed since the most recent level 0 backup) or differential (including only blocks changed since the most recent incremental backup, whether it is level 0 or level 1).
Incremental backups are generally smaller and faster to create than full database backups. Recovery from an incremental backup is faster than recovery using redo logs alone. During a restore from incremental backup, the level 0 backup is used as the starting point, then changed blocks are updated based on level 1 backups where possible to avoid re-applying changes from redo one at a time. Recovering with incremental backups requires no additional effort on your part. If incremental backups are available, RMAN will use them during recovery.
Incrementally Updated Backups
RMAN's incrementally updated backups feature allows for a more efficient incremental backup routine. Changes from level 1 backups can be used to roll forward an image copy level 0 incremental backup, so that it includes all changes as of the SCN at which the level 1 incremental backup was created. Recovery using the updated level 0 incremental backup is faster, because all changes from the level 1 incremental backup have already been applied.
See Oracle Database Backup and Recovery Basics for more details and examples for incremental backups and incrementally updated backups.
Validating Backups
You can run a test RMAN backup that does not generate any output. Validation confirms that a backup could be run, by confirming that all database files exist, are in their correct location, and are free of physical and logical corruption. For example:
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;