Oracle-RMAN backup

Source: Internet
Author: User

I. concepts related to RMAN backup

1. in RMAN backup, The tablespace does not need to be in backup mode. It backs up data files, archive log files, control files, spfiles, and backup sets, but does not back up online redo log files, temporary files and password files.

2. the backup set consists of one or more backup slices. The size of the backup file is related to the operating system. The maximum file size of a 32-bit operating system is 4 GB.

3. data file backup sets support both full and Incremental backup, that is, only used blocks are backed up, which is not supported by archived log file backup sets.

4. Run the common view command in RMAN. show all is used to view the default backup parameters, report schema is used to view the data table space and data file information, and list back is used to view the information of the backup file.

There is a default file backup control problem in show all, and the control file backup is not backed up by default,

Configure controlfile autobackup off; # default

If you back up the system tablespace files, the control files are automatically backed up, whether off or on.

5. common parameters: maxpiecesize specifies the size of the backup piece and the size of the maxsetsize backup set. filesperset indicates the number of input files contained in a backup set, % U = % u _ % p _ % c to generate a unique name.

6. In RMAN backup, you can divide the backup file into two parts, one is the data file backup set, the other is the archive log file, and the control file and the spfile are compressed and packaged together.

Recommended reading:

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

Ii. RMAN backup method

1. In non-archive mode, consistent backup must be performed. For RMAN consistent backup, the database must be in load mode and shut down cleanly. The backup can be complete or incremental.

2. in archive mode, you can perform consistent or non-consistent backup. archive log files must be backed up in non-consistent backup. The backup can be all, partial, complete, or incremental.

Backup can be divided into full, local, complete, or Incremental backup. Only RMAN can implement Incremental backup.

Iii. RMAN backup of various files

(1) backup data files

Report schema displays information about various tablespaces and data files.

RMAN> report schema;

Report of database schema for database with db_unique_name WILSON

List of Permanent Datafiles

======================================

File Size (MB) Tablespace RB segs Datafile Name

---------------------------------------------------------------

1 760 SYSTEM ***/u01/oradata/wilson/system01.dbf

2 580 SYSAUX ***/u01/oradata/wilson/sysaux01.dbf

3 135 UNDOTBS1 ***/u01/oradata/wilson/undotbs01.dbf

4 28 USERS ***/u01/oradata/wilson/users01.dbf

5 100 EXAMPLE ***/u01/oradata/wilson/example01.dbf

6 20 PAUL ***/u01/oradata/wilson/paul01.dbf

7 20 SUN ***/u01/oradata/wilson/sun01.dbf

8 2 SMALLUNDO ***/u01/oradata/wilson/smallundo1.dbf

9 100 ASSM ***/u01/oradata/wilson/assm_1.dbf

10 100 MSSM ***/u01/oradata/wilson/mssm_1dbf

11 10 PAUL ***/u01/oradata/wilson/paul02.dbf

List of Temporary Files

======================================

File Size (MB) Tablespace Maxsize (MB) Tempfile Name

---------------------------------------------------------------

1 29 TEMP 32767/u01/oradata/wilson/temp01.dbf

2 100 MYTEMP 100/u01/oradata/wilson/mytemp01.dbf

You can also see it in SQL * plus.

SQL> select file #, name from v $ datafile;

FILE # NAME

---------------------------------------------

1/u01/oradata/wilson/system01.dbf

2/u01/oradata/wilson/sysaux01.dbf

3/u01/oradata/wilson/undotbs01.dbf

4/u01/oradata/wilson/users01.dbf

5/u01/oradata/wilson/example01.dbf

6/u01/oradata/wilson/paul01.dbf

7/u01/oradata/wilson/sun01.dbf

8/u01/oradata/wilson/smallundo1.dbf

9/u01/oradata/wilson/assm_1.dbf

10/u01/oradata/wilson/mssm_1dbf

11/u01/oradata/wilson/paul02.dbf

11 rows selected.

You can use the following commands to successfully back up data,

RMAN> backup datafile 4 format = '/u01/backup/md _ % U ';

Or

RMAN> backup datafile '/u01/oradata/wilson/users01.dbf' format ='/u01/backup/md _ % U ';

Starting backup at 23-AUG-13

Using channel ORA_DISK_1

Channel ORA_DISK_1: starting full datafile backup set

Channel ORA_DISK_1: specifying datafile (s) in backup set

Input datafile file number = 00004 name =/u01/oradata/wilson/users01.dbf

Channel ORA_DISK_1: starting piece 1 at 23-AUG-13

Channel ORA_DISK_1: finished piece 1 at 23-AUG-13

Piece handle =/u01/backup/md_1hoi1t5t_1_1 tag = TAG20130823T202948 comment = NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 23-AUG-13

(2) backup tablespace

Similar to backing up data files, report schema is used to view table space information. Only commands are slightly different, as shown below:

RMAN> backup tablespace sun format = '/u01/backup/ts _ % U ';

Starting backup at 23-AUG-13

Using channel ORA_DISK_1

Channel ORA_DISK_1: starting full datafile backup set

Channel ORA_DISK_1: specifying datafile (s) in backup set

Input datafile file number = 00007 name =/u01/oradata/wilson/sun01.dbf

Channel ORA_DISK_1: starting piece 1 at 23-AUG-13

Channel ORA_DISK_1: finished piece 1 at 23-AUG-13

Piece handle =/u01/backup/ts_1ioi1tdv_1_1 tag = TAG20130823T203407 comment = NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 23-AUG-13

(3) backup control files

1. Enable automatic backup control file

RMAN> show all;

RMAN configuration parameters for database with db_unique_name WILSON are:

Configure controlfile autobackup off; # default

Configure controlfile autobackup format for device type disk to '/u01/backup/ctl _ % F ';

......

It can be seen that it is off by default and is changed to on,

RMAN> configure controlfile autobackup on;

New RMAN configuration parameters:

Configure controlfile autobackup on;

New RMAN configuration parameters are successfully stored

Check again to confirm,

RMAN> show all;

RMAN configuration parameters for database with db_unique_name WILSON are:

Configure controlfile autobackup on;

Configure controlfile autobackup format for device type disk to '/u01/backup/ctl _ % F ';

The configure controlfile autobackup format for device type disk to '/u01/backup/ctl _ % F' command can control the file backup TO the desired address.

This automatic backup control file will also back up the spfile together.

2. Direct backup, but it does not back up spfile. The command is as follows,

RMAN> backup current controlfile;

Starting backup at 23-AUG-13

Using channel ORA_DISK_1

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

Channel ORA_DISK_1: starting piece 1 at 23-AUG-13

Channel ORA_DISK_1: finished piece 1 at 23-AUG-13

Piece handle =/tmp/back/1joi1unc_1_1 tag = TAG20130823T205612 comment = NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04

Finished backup at 23-AUG-13

3. You can add backups when backing up data files or tablespaces, but it does not back up spfiles. The command is as follows:

RMAN> backup datafile 4 include current controlfile;

Or

RMAN> backup tablespace sun include current controlfile;

(4) backing up spfile

When the automatic backup control file is enabled, spfile is automatically backed up.

You can also use the following command to back up data,

RMAN> backup spfile format '/u01/backup/sp _ % U ';

Starting backup at 23-AUG-13

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID = 44 device type = DISK

Channel ORA_DISK_1: starting full datafile backup set

Channel ORA_DISK_1: specifying datafile (s) in backup set

Including current SPFILE in backup set

Channel ORA_DISK_1: starting piece 1 at 23-AUG-13

Channel ORA_DISK_1: finished piece 1 at 23-AUG-13

Piece handle =/u01/backup/sp_1qoi23po_1_1 tag = TAG20130823T222247 comment = NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 23-AUG-13

Starting Control File and SPFILE Autobackup at 23-AUG-13

Piece handle =/u01/backup/ctl_c-3925834152-20130823-0a comment = NONE

Finished Control File and SPFILE Autobackup at 23-AUG-13

We can see that although the command only backs up spfile, the control file is also backed up.

(5) backup and archive log files

To back up an archive log file, copy all the content. The command is as follows,

RMAN> backup archivelog all format = '/u01/backup/ac _ % U' delete all input;

Delete all input deletes the original archive log file.

When executing this command, the system checks whether the archive log file is damaged. If a local archive log file is damaged, the system automatically reads the archive log file from another place, if all data is damaged, the backup is rejected.

To ensure consistency of archived logs, perform the following operations when backing up archived log files,

1. After the BACKUP command starts, run the alter system archive log current command to copy the online redo log file to the archive log file.

2. Back up archive log files or back up data files together with archive log files.

3. run the alter system archive log current command again (because the previous step may take a long time, this time period will generate redo information, so you need to copy the online redo log file to the archived log file ).

4. Back up the archived log file again.

Or use the following command,

Backup archivelog sequence between 139 and 141 thread 1 delete (all) input;

You can select the backup range of sequence;

Or

Backup archivelog from time "sysdate-15" until time "sysdate-7 ";

You can select a time range to back up archived log files;

Alternatively, you can back up the archived log files when backing up data files,

Backup database plus archivelog format = '/u01/backup/db _ % U '.

More common

  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.