0% found this document useful (0 votes)
2 views

_RMAN Backup Script for Full DB, Archives &Control Files

This RMAN script for Oracle databases performs a comprehensive backup of the database, archive logs, and control files, ensuring consistency through log switches and checkpoints. It utilizes multiple channels for parallel processing and compression to enhance efficiency. The script includes steps for verifying existing backups and releasing resources after the backup process is complete.

Uploaded by

decegam797
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

_RMAN Backup Script for Full DB, Archives &Control Files

This RMAN script for Oracle databases performs a comprehensive backup of the database, archive logs, and control files, ensuring consistency through log switches and checkpoints. It utilizes multiple channels for parallel processing and compression to enhance efficiency. The script includes steps for verifying existing backups and releasing resources after the backup process is complete.

Uploaded by

decegam797
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

## RMAN (Recovery Manager) script for Oracle databases, used to perform a

backup of the database, archive logs, and control files:-

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

allocate channel c5 type disk;

sql 'alter system switch logfile';

sql 'alter system switch logfile';

sql 'alter system checkpoint';

crosscheck backup;

backup as copy current controlfile format '/oradata/RMAN/control_before_backup_%T.ctl';

backup as compressed backupset database format '/oradata/RMAN/%d_%s_%T_%p';

backup as compressed backupset archivelog all format


'/oradata/RMAN/arch_%d_%s_%T_%p';

backup as copy current controlfile format '/oradata/RMAN/control_after_backup_%T.ctl';

release channel c1;

release channel c2;

release channel c3;

release channel c4;

release channel c5;

}
====== =====================

Complete description about above script:-

This is an RMAN (Recovery Manager) script for Oracle databases, used to perform a
backup of the database, archive logs, and control files. Here's a detailed explanation of
each part:

1. RUN Block
The RUN block is used to group RMAN commands into a single executable block.

2. Allocate Channels
allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

allocate channel c5 type disk;

1. Purpose: Allocates channels, which are RMAN connections to the database and
target storage.
2. type disk: Specifies that the backups will be written to disk.
3. Here, five channels (c1 to c5) are allocated for parallel processing, enabling faster
backups by distributing the workload.

3. Switch Log Files


sql 'alter system switch logfile';

sql 'alter system switch logfile';

1. Purpose: Manually forces the database to switch its current redo log file to the next
one in the redo log group.
2. This ensures that all redo information is written to disk and included in the backup,
making the backup consistent.

4. Perform a Checkpoint
sql 'alter system checkpoint';

1. Purpose: Forces a checkpoint, ensuring that all dirty buffers in the memory (SGA)
are written to the datafiles.
2. This guarantees that the database is in a consistent state for the backup.

5. Crosscheck Backup
crosscheck backup;

1. Purpose: Verifies the availability and status of existing backups in the RMAN
repository.
2. Any missing or corrupt backups will be marked accordingly in the RMAN catalog.

6. Backup Control File Before Database Backup


backup as copy current controlfile format '/oradata/RMAN/control_before_backup_%T.ctl';

1. Purpose: Creates a copy of the current control file before performing the
database backup.
2. Format: The %T in the file name is a substitution variable that inserts the current
date in YYYYMMDD format.

7. Backup the Database


backup as compressed backupset database format '/oradata/RMAN/%d_%s_%T_%p';

1. Purpose: Creates a compressed backup of the entire database.


2. Backupset: RMAN groups the data into smaller pieces for efficient storage.
3. Format Variables:
1. %d: Database name.
2. %s: Backup set number.
3. %T: Date in YYYYMMDD format.
4. %p: Piece number within the backup set.

8. Backup Archive Logs


backup as compressed backupset archivelog all format
'/oradata/RMAN/arch_%d_%s_%T_%p';

1. Purpose: Creates a compressed backup of all archived redo logs.


2. Why Archive Logs?: Ensures all redo information (used for recovery) is backed up,
especially useful for point-in-time recovery.

9. Backup Control File After Database Backup


backup as copy current controlfile format '/oradata/RMAN/control_after_backup_%T.ctl';

1. Purpose: Creates a copy of the control file after the database backup.
2. This is essential to capture any changes that occurred during the backup process,
such as new archived logs being generated.

10. Release Channels


release channel c1;

release channel c2;

release channel c3;

release channel c4;

release channel c5;

1. Purpose: Frees up the allocated RMAN channels once the backup process is
complete.
2. This is a best practice to avoid resource contention.
Summary of the Script

1. Preparation: Allocates channels and ensures database consistency by switching


log files and performing a checkpoint.
2. Backup Tasks: Backs up the control file (before and after the backup), the entire
database, and all archive logs.
3. Efficiency: Uses compression and parallelism (multiple channels) for faster and
space-efficient backups.
4. Cleanup: Releases the channels after the backup process is completed.

This script is designed for full database backups along with archive logs, ensuring the
database is recoverable to a consistent state.

# [email protected]

https://www.linkedin.com/in/rashid-khan-856b53232

You might also like