Components and comments of the backup script

1, Basic components: 1.Server session: ...

1, Basic components:

1.Server session:

Server session, the process on the server, is really used to work

2.Channel:

Is a channel used to connect the database with the backup storage medium;

Channel configuration options:

connect :It's a Oracle Net Connection string. Generally not applicable to single instance environments format : Determine the path and file name for the backup slice or image copy created for the channel duration: Controls the total amount of time for the job, specified in hours and minutes maxopenfiles:This option limits RMAN The number of input files that can be opened at one time. The default is maxpiecesize:Limit the size of a backup slice divided by a backup set in bytes(default),k,m,g Unit parms:Can be used to set sbt_type Any variables required by the channel filesperset:Number of files in the backup set backup set: Is a collection, Is composed of one or more physical files, Is a logical unit. backup piece: Is a real output file, Limited by a single file of the operating system, Namely maxpiecesize This parameter;

3.backuppiece:

  Backup slice, which represents a backup file generated by Rman, can be seen when working with os

4.backupset:

A backup set is a logical concept that represents the collection of all backup pieces generated by a backup

A data file can exist across backup slices, but not across backup sets

2, Basic job template:

  Example 1:

RMAN> run { allocate channel c1 device type disk maxpiecesize 1500m; backup database plus archivelog delete all input; release channel c1; }

The allocate channel command starts a server process in the target database. At the same time, it must define the I/O type used by the server process to perform backup or recovery operations

The maximum size of each backup slice is 1500M. If it exceeds this size, a new backup slice will be generated, the current log will be archived, a backup slice will be generated, and the backed up archive log will be deleted

Then back up the data file, generate two backup pieces (data file 2G), back up the current spfile and control file, generate a backup piece, and finally do logwatch again,

Backup the archive log and generate a backup slice. Therefore, it can be described as follows: this backup set contains five backup slices, and one backup slice contains files specified by filespherset.

Example 2:

RMAN> run { allocate channel c1 device type disk maxpiecesize 1500m; backup database filesperset 1; release channel c1; }

It means that a backup piece contains a file. Even if it does not reach 1500M, a new backup piece will be generated. For example, mine has five data files and one backup piece of SPFILE and CONTROLFILE

Generate six backup slices if plus archivelog   If the backup option delete all input is selected, the parameter FILESPERSET will be ignored.

3, RMAN backup script:

1. All ready:

$cat arch_rman_backup.sh:

source /home/oracle/.bash_profile rman target / log=/u01/app/script/arch_rman.log<<EOF run { allocate channel ch1 device type disk; allocate channel ch2 device type disk; sql 'alter system archive log current'; sql 'alter system archive log current'; backup archivelog all format '/backup/arch_%U_%d_%T_%t' delete all input; backup current controlfile format '/backup/ctl_%U_%d_%T_%t'; crosscheck backup; crosscheck archivelog all; delete noprompt expired backup; delete noprompt obsolete; #delete noprompt backup of database completed before 'sysdate -7'; #delete noprompt archivelog all; #delete noprompt backup of archivelog all completed before 'sysdate -7'; release channel ch1; release channel ch2; } EOF

2. Archive log backup:

$cat arch_rman_backup.sh

source /home/oracle/.bash_profile rman target / log=/u01/app/script/arch_rman.log<<EOF run { allocate channel ch1 device type disk; allocate channel ch2 device type disk; sql 'alter system archive log current'; #backup database format '/backup/db_%d_%T_%U'; sql 'alter system archive log current'; backup archivelog all format '/backup/arch_%U_%d_%T_%t' delete all input; backup current controlfile format '/backup/ctl_%U_%d_%T_%t'; crosscheck backup; crosscheck archivelog all; delete noprompt expired backup; delete noprompt obsolete; #delete noprompt backup of database completed before 'sysdate -7'; #delete noprompt archivelog all; #delete noprompt backup of archivelog all completed before 'sysdate -7'; release channel ch1; release channel ch2; } EOF

4 December 2021, 00:49 | Views: 9679

Add new comment

For adding a comment, please log in
or create account

0 comments