Backup Recovery   «Prev  Next»

Lesson 4Creating backup scripts
Objective Create a backup script.

Creating Backup Scripts in Oracle

Now that you have created a catalog, you need to register your target database with the catalog you have created.
This populates the catalog with initial information regarding the configuration of your target database and includes a full synchronization of the catalog with the control file of the target database.

Another good reason for performing backup

If you lose your catalog, you can partially regenerate it from the information within the control file, but you should avoid this predicament by backing it up. You can use RMAN to back up the catalog by creating a recovery-catalog schema within one of your other instances, by using that as the catalog for your primary catalog instance. Providing that these two instances do not share any common resources, this role reversal is free from single points of failure.

Update your catalog with RESYNC CATALOG

It is important that your recovery catalog has an up-to-date view of your database. When you execute RMAN operations on the database, RMAN automatically synchronizes the catalog with the target. However, depending on the volatility of your database, you may need to resynchronize the catalog more frequently. Always include catalog resynchronization as part of any structural database change (the addition of files, tablespaces, and so on) and ensure that a resynchronization occurs at intervals. To perform this action, issue the RESYNC CATALOG command from within RMAN.
Now you are ready to produce your first backups. You can enter RMAN commands interactively, or you can hold them within RMAN-stored scripts or operating-system command files.

RMAN within Windows

Initiating RMAN within a Microsoft Windows environment involves unique commands:

C:\> RMAN 
RMAN> CONNECT TARGET RMAN/RMAN@PETS
RMAN> CONNECT RCVCAT RMAN/RMAN@BACKUP
RMAN> # then enter your RMAN commands here
C:\>

The first command connects to the target database (the database that you want to back up). You connect to the recovery catalog through the second command.

Create database backups

The following code backs up your entire database, including a copy of the current control file:
RMAN> RUN {
2> ALLOCATE CHANNEL C1 TYPE DISK;
3> BACKUP DATABASE FORMAT 'D:\BACKUPS\%U';
4> RELEASE CHANNEL C1;
5> }

The next lesson uses the FORMAT parameter.