Oracle-策略-RMAN(恢复管理器)-BACKUP(备份)

    Recovery Manager (RMAN) is an Oracle Database client that performs backup and recovery tasks on your databases and automates administration of your backup strategies. It greatly simplifies backing up, restoring, and recovering database files.

    RMAN组成部分:The RMAN environment consists of the utilities and databases that play a role in backing up your data. At a minimum, the environment for RMAN must include the following components:

    A target database
        An Oracle database to which RMAN is connected with the TARGET keyword. A target database is a database on which RMAN is performing backup and recovery operations. RMAN always maintains metadata about its operations on a database in the control file of the database. The RMAN metadata is known as the RMAN repository.
    The RMAN client
        An Oracle Database executable that interprets commands, directs server sessions to execute those commands, and records its activity in the target database control file. The RMAN executable is automatically installed with the database(自动伴随数据库安装) and is typically located in the same directory as the other database executables. For example, the RMAN client on Linux is located in $ORACLE_HOME/bin.

   RMAN Commands更多信息连接: https://docs.oracle.com/cd/B28359_01/backup.111/b28273/rcmsynta.htm#RCMRF1960

Example Connecting to a Target Database from the System Prompt(RMAN连接目标数据库示例)

% rman TARGET SYS@prod NOCATALOG
target database Password: password
connected to target database: PROD (DBID=39525561)
--RMAN commands Examples(命令示例)
BACKUP --Example 2-15 Backing Up a Database --This example starts the RMAN client from the operating system command line(启动RMAN方式) and then connects to a target database using operating system authentication.
--The BACKUP command backs up all datafiles, the current control file, the server parameter file, and archived redo log files to the default storage device:
% rman RMAN> CONNECT TARGET / RMAN> BACKUP DATABASE PLUS ARCHIVELOG; --Example 2-16 Performing a Cumulative Incremental Backup --This example backs up all blocks changed in the database since the most recent level 0 incremental backup.
--If no level 0 backup exists when you run a level 1 backup, then RMAN makes a level 0 backup automatically. Any inaccessible files are skipped.
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SKIP INACCESSIBLE DATABASE; --Example 2-17 Distributing a Backup Across Multiple Disks --This example backs up tablespaces to two different disks and lets RMAN perform automatic parallelization of the backup.
--The %U in the FORMAT string is a substitution variable that generates a unique filename for each output image copy.
RUN { ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/disk1/%U'; ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/disk2/%U'; BACKUP AS COPY TABLESPACE SYSTEM, tools, users, undotbs; } --Example 2-18 Identifying Datafile Copies by Tag --In this example, you back up datafile image copies to tape. The BACKUP command locates all datafile copies with the tag LATESTCOPY, backs them up to tape, and names the backups by means of substitution variables.
--The variable %f specifies the absolute file number, whereas %d specifies the name of the database. After the datafile copies are on tape, the example deletes all image copies with the tag LATESTCOPY.
BACKUP DEVICE TYPE sbt DATAFILECOPY FROM TAG 'LATESTCOPY' FORMAT 'Datafile%f_Database%d'; DELETE COPY TAG 'LATESTCOPY'; --Example 2-19 Backing Up and Deleting Archived Redo Logs --This example assumes that you have two archiving destinations set: /disk2/PROD/archivelog/ and /disk1/arch/. The command backs up one archived redo log for each unique sequence number.
--For example, if archived redo log 1000 is in both directories, then RMAN only backs up one copy this log. The DELETE INPUT clause with the ALL keyword specifies that RMAN should delete all archived redo log files from both archiving directories after the backup.
BACKUP DEVICE TYPE sbt ARCHIVELOG LIKE '/disk%arc%' DELETE ALL INPUT;

 

退出:To quit RMAN and terminate the program, enter EXIT or QUIT at the RMAN prompt:

RMAN> EXIT

 

Examples

Example 2-15 Backing Up a Database

This example starts the RMAN client from the operating system command line and then connects to a target database using operating system authentication. The BACKUP command backs up all datafiles, the current control file, the server parameter file, and archived redo log files to the default storage device:

% rman
RMAN> CONNECT TARGET /
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

Example 2-16 Performing a Cumulative Incremental Backup

This example backs up all blocks changed in the database since the most recent level 0 incremental backup. If no level 0 backup exists when you run a level 1 backup, then RMAN makes a level 0 backup automatically. Any inaccessible files are skipped.

BACKUP 
  INCREMENTAL LEVEL 1 CUMULATIVE
  SKIP INACCESSIBLE 
  DATABASE;

Example 2-17 Distributing a Backup Across Multiple Disks

This example backs up tablespaces to two different disks and lets RMAN perform automatic parallelization of the backup. The %U in the FORMAT string is a substitution variable that generates a unique filename for each output image copy.

RUN
{
  ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/disk1/%U';
  ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/disk2/%U'; 
  BACKUP AS COPY
    TABLESPACE SYSTEM, tools, users, undotbs;
}

Example 2-18 Identifying Datafile Copies by Tag

In this example, you back up datafile image copies to tape. The BACKUP command locates all datafile copies with the tag LATESTCOPY, backs them up to tape, and names the backups by means of substitution variables. The variable %f specifies the absolute file number, whereas %d specifies the name of the database. After the datafile copies are on tape, the example deletes all image copies with the tag LATESTCOPY.

BACKUP 
  DEVICE TYPE sbt
  DATAFILECOPY 
    FROM TAG 'LATESTCOPY'
  FORMAT 'Datafile%f_Database%d';
DELETE COPY TAG 'LATESTCOPY';

Example 2-19 Backing Up and Deleting Archived Redo Logs

This example assumes that you have two archiving destinations set: /disk2/PROD/archivelog/ and /disk1/arch/. The command backs up one archived redo log for each unique sequence number. For example, if archived redo log 1000 is in both directories, then RMAN only backs up one copy this log. The DELETE INPUT clause with the ALL keyword specifies that RMAN should delete all archived redo log files from both archiving directories after the backup.

BACKUP DEVICE TYPE sbt
  ARCHIVELOG LIKE '/disk%arc%'
  DELETE ALL INPUT;

你可能感兴趣的:(Oracle-策略-RMAN(恢复管理器)-BACKUP(备份))