This module discussed the backup and recovery processes within Oracle.
Learning about the backup and recovery scripts is certain to help you better manage your database.
Now that you have completed this module, you should be able to:
- Explain the new features of RMAN
- Create a recovery catalog
- Create and run a backup script in RMAN
- Describe the new feature of specifying a character set for a control file
- Recover a failed database by using the line mode of RMAN
- Recover a failed database by using the RMAN GUI
To create an RMAN backup script in Oracle 12c, you can use the following steps:
- Start RMAN and connect to the target database and recovery catalog.
- Use the `CREATE SCRIPT` command to create the script. You can specify the name of the script and the backup commands that you want to include.
- Once you have created the script, you can run it using the `EXECUTE SCRIPT` command.
Here is an example of a simple RMAN backup script:
CREATE SCRIPT backup_script;
RUN {
BACKUP DATABASE;
};
EXECUTE SCRIPT backup_script;
This script will back up the entire database. You can modify the script to back up specific tablespaces or files, or to use different backup options. You can also create more complex RMAN backup scripts that include multiple backup commands, conditional logic, and loops. For example, you could create a script that backs up different tablespaces at different times of day, or a script that backs up the database only if there have been changes since the last backup. Once you have created an RMAN backup script, you can run it manually or schedule it to run automatically using the Oracle Scheduler.
Here is an example of how to schedule an RMAN backup script to run automatically:
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name => 'backup_job',
job_type => 'EXECUTED_PROCEDURE',
job_action => 'BACKUP_SCRIPT',
start_date => SYSDATE,
repeat_interval => 'FREQ=DAILY',
end_date => NULL,
enabled => YES);
END;
This will create a job called `backup_job` that will run the `BACKUP_SCRIPT` procedure every day.
You can also use the Oracle Enterprise Manager Console to create and schedule RMAN backup scripts.
Each protected database that stores backups to a Recovery Appliance must have a globally unique database name (DB_UNIQUE_NAME).
This global database name is used to identify the protected database to which a backup belongs.
Backups for a protected database are written to the storage location that is specified in the protection policy associated with the protected database.