Use RMAN for backup

Source: Internet
Author: User

1. Back up the database

 

RMAN> show all;

 

RMAN configuration parameters are:

Configure retention policy to redundancy 1; # default

Configure backup optimization off; # default

Configure Default device type to disk; # default

Configure controlfile autobackup off; # default

Configure controlfile autobackup format for device type disk to '% F'; # default

Configure device type disk parallelism 1 Backup Type to backupset; # default

Configure datafile backup copies for device type disk to 1; # default

Configure archivelog backup copies for device type disk to 1; # default

Configure Channel Device Type disk format '/u01/APP/Oracle/rmanbak/DF _ % d _ % U ';

Configure maxsetsize to unlimited; # default

Configure encryption for database off; # default

Configure encryption algorithm 'aes128 '; # default

Configure archivelog deletion policy to none; # default

Configure snapshot controlfile name to '/u01/APP/Oracle/10g/dbs/snapcf_orcl.f'; # defaul

 

RMAN> backup database format '/u01/APP/Oracle/rmanbak/whole _ % d _ % U'; -- backup the entire database

 

RMAN> Backup as compressed backupset -- back up the entire database and compress the backup set

2> database format'/u01/APP/Oracle/rmanbak/whole _ % d _ % U ';

 

RMAN> run {

2> allocate channel allocation type disk -- manually allocate a channel

3> maxpiecesize = 2G; -- specify the size of the backup slice as G

4> Backup as compressed backupset -- compression backup set

5> Format '/u01/APP/Oracle/rmanbak/whole _ % d _ % U' filesperset = 3 -- specify the number of files allowed in the backup set

6> database;

7> release channel release;} -- Release Channel

 

RMAN> Configure device type disk parallelism 3; -- change the degree of parallelism

 

Old rman configuration parameters:

Configure device type disk parallelism 1 Backup Type to backupset;

New RMAN configuration parameters:

Configure device type disk parallelism 3 Backup Type to backupset;

New RMAN configuration parameters are successfully stored

 

RMAN> Backup as compressed backupset -- after the degree of parallelism is changed, a channel is automatically enabled.

2> Format '/u01/APP/Oracle/rmanbak/whole _ % d _ % U' filesperset = 3

3> database;

 

Starting backup at 14--10 -10

Allocated channel: ora_disk_1

Channel ora_disk_1: SID = 148 devtype = disk -- sid value corresponds to Sid in the V $ session View

Allocated channel: ora_disk_2

Channel ora_disk_2: SID = 146 devtype = Disk

Allocated channel: ora_disk_3

Channel ora_disk_3: SID = 144 devtype = Disk

 

RMAN> run {

2> allocate channel category type Disk

3> maxpiecesize = 100 m; -- if the size of the backup part is set to m, a backup set contains multiple backup parts, and the size of each backup part is M.

4> Backup

5> Format '/u01/APP/Oracle/rmanbak/whole _ % d _ % U'

6> database;

7> release channel success ;}

 

RMAN> List backupset tag = tag20101014t171115;

 

List of backup Sets

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

 

BS key Type LV Size Device Type elapsed time completion time

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

21 full 690.30 M Disk 00:01:39 14--10 -10

List of datafiles in backup set 21

File LV type ckp scn ckp time name

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

1 full 1648791 14-oct-10/u01/APP/Oracle/oradata/orcl/system01.dbf

2 full 1648791 14-oct-10/u01/APP/Oracle/oradata/orcl/undotbs01.dbf

3 full 1648791 14-oct-10/u01/APP/Oracle/oradata/orcl/sysaux01.dbf

4 full 1648791 14-oct-10/u01/APP/Oracle/oradata/orcl/users01.dbf

5 full 1648791 14-oct-10/u01/APP/Oracle/oradata/orcl/example01.dbf

6 full 1648791 14-oct-10/u01/APP/Oracle/oradata/orcl/tbs1.dbf

 

Backup set copy #1 of backup set 21

Device Type elapsed time completion time compressed tag

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

Disk 00:01:39 14--10 -10 no tag20101014t171115

 

List of backup pieces for backup set 21 copy #1

BP key PC # status piece name

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

21 1 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_1_1

22 2 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_2_1

23 3 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_3_1

24 4 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_4_1

25 5 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_5_1

26 6 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_6_1

27 7 available/u01/APP/Oracle/rmanbak/whole_orcl_0nlqemtj_7_1

 

BS key Type LV Size Device Type elapsed time completion time

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

22 full 6.80 m disk 00:00:01 14--10 -10

BP key: 28 Status: available compressed: No tag: tag20101014t171115

Piece name:/u01/APP/Oracle/rmanbak/whole_orcl_0olqen0s_1_1

Control file included: ckp scn: 1648817 CKP time: 14-oct-10

Spfile encoded ded: modification time: 14-oct-10

 

Bytes -----------------------------------------------------------------------------------------------------------------------

2. Back up data files

For management of ORACLE data files and tablespaces, see Oracle tablespace and data files.

RMAN> Backup as copy datafile 4 -- Backup Type is image backup

2> Format '/u01/APP/Oracle/rmanbak/DF _ % d _ % U ';

 

RMAN> List copy;

 

RMAN> Backup datafile, 6 format'/u01/APP/Oracle/rmanbak/DF _ % d _ % U'; -- backup set

 

Bytes -----------------------------------------------------------------------------------------------------------------------

3. Backup tablespace

For management of ORACLE data files and tablespaces, see Oracle tablespace and data files.

 

RMAN> Backup tablespace users, Example format '/u01/APP/Oracle/rmanbak/Tb _ % d _ % U ';

 

RMAN> Backup tablespace temp; -- temporary tablespace does not need to be backed up

 

Starting backup at 14--10 -10

Using channel ora_disk_1

Using channel ora_disk_2

RMAN-00571: ========================================================== ==============================

RMAN-00569: ==================== error message stack follows ==========================

RMAN-00571: ========================================================== ==============================

RMAN-03002: failure of Backup command at 10/14/2010 18:56:12

RMAN-20202: tablespace not found in the recovery catalog

RMAN-06019: cocould not translate tablespace name "Temp"

 

Bytes -----------------------------------------------------------------------------------------------------------------------

4. Backup Control File

For details about the Oracle control file, refer to: Oracle control file (controlfile)

 

RMAN> Configure controlfile autobackup on; -- set the automatic backup control file to on, and set the automatic backup control file and parameter file

 

Old rman configuration parameters:

Configure controlfile autobackup off;

New RMAN configuration parameters:

Configure controlfile autobackup on;

New RMAN configuration parameters are successfully stored

 

Note: When backing up the system01.dbf or system tablespace, the control files and parameter files are automatically backed up, even if the automatic backup control file parameter is off.

 

-- Backup control files and parameter files separately

RMAN> Backup current controlfile;

 

-- Include a control file when backing up data files

RMAN> Backup datafile 4 include current controlfile;

 

RMAN> SQL "alter Database Backup controlfile to''/tmp/orclcontrol. Bak ''";

 

SQL statement: Alter Database Backup controlfile to ''/tmp/orclcontrol. Bak''

 

RMAN> SQL "alter Database Backup controlfile to trace as''/tmp/orclcontrol. SQL ''";

 

SQL statement: Alter Database Backup controlfile to trace as ''/tmp/orclcontrol. SQL''

 

-- Backup spfile separately

RMAN> Backup spfile format '/u01/APP/Oracle/rmanbak/SP _ % d _ % U ';

 

RMAN> backup copies 2 device type disk spfile;

 

Bytes -----------------------------------------------------------------------------------------------------------------------

5. Back up archived log files

Only archived data files are backed up when archiving logs are backed up (online redo log files are not backed up)

Archive logs are always backed up completely.

RMAN automatically performs a log switch before backing up archive logs, and backs up intact archive logs from a group of archive logs.

RMAN automatically determines which archived logs need to be backed up.

The backup set for archiving logs cannot contain other types of files.

 

For more information about Oracle log files, see Oracle online redo log files)

For more information about Oracle archiving logs, see Oracle archiving logs.

 

RMAN> Backup

2> Format '/u01/APP/Oracle/rmanbak/LF _ % d _ % U'

3> archivelog all Delete input; -- delete input: delete all archived logs that have been backed up.

 

RMAN> backup -- this method implements the same functions above

2> archivelog all Delete Input

3> Format '/u01/APP/Oracle/rmanbak/LF _ % d _ % U ';

 

RMAN> Backup archivelog sequence between 50 and 120 thread 1 Delete input;

 

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

RMAN> Backup

2> Format '/u01/APP/Oracle/rmanbak/LF _ % d _ % U'

3> archivelog from sequence = 80

4> Delete input;

 

Backup Database Plus archivelog)

1. First run the alter system archive log current command to archive the current log)

2. Run the backup archivelog all command to back up all archived logs)

3. Execute the specified data file and tablespace in the backup database command.

4. Execute alter system archive log current again

5. Back up the new archive logs generated during the backup operation

 

-- Execute the following command and observe the information listed in the backup. We can see that the steps described above are used for backup when plus archivelog is used.

RMAN> Backup Database Plus archivelog

2> Format '/u01/APP/Oracle/rmanbak/LG _ % d _ % U' Delete input;

 

6. backup flash back area

RMAN> Backup recovery area;

When the Backup recovery area is used, all files that are located in the flash back area and have not been backed up are backed up. These files include complete, Incremental Backup sets, automatic backup

Control Files (assuming that the flash back area is used as the backup path), archived logs, image copies of data files, and so on. Flash Back log, the current control file.

Online redo logs are not backed up

RMAN> Backup recovery files;

When you use Backup recovery files, all recovery files that have not been backed up on the backup disk are backed up, regardless of whether they are in the flash back area.

Note: when using the above two commands, the backup destination must be a tape

7. Conclusion:

Backup sets of data files can perform Incremental backup for unused blocks. You can skip unused data blocks for compressed backup.

The control files, archived log files, and spfile files are simply copied and compressed.

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.