In the previous examples, we have some knowledge about it and tried some commands related to Oracle actual RMAN backup. However, in the actual operating environment, it is impossible to require DBAs to execute a command and a command to repeat the previous chapter. We are determined to optimize the work.
Therefore, we should write a script and put it on the server for regular execution. DBA only needs to regularly check the results of script execution.
Before writing a script, let's clarify our goals:
Run the command at 1 o'clock every night.
Database full backup, backup control files and archive log files at the same time, backup files are saved to the F: \ oracle \ backup \ directory, and after archiving log files are backed up, the archived logs backed up are automatically deleted.
The backup is retained for 14 days, and is automatically deleted after expiration.
Keep operation logs for future reference.
Taking a Windows environment as an example, the Linux/u nix environment is basically similar. You do not need to change the RMAN script or even change it, modify the command line that calls the RMAN script and the backup set storage path!
8.6.1 compile the RMAN batch processing file
Compile the RMAN batch file:
- RUN {
- CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
- CONFIGURE CONTROLFILE AUTOBACKUP ON;
- CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
DEVICE TYPE DISK TO ' F:\ORACLE\BACKUP\%F ' ;
- ALLOCATE CHANNEL C1 DEVICE TYPE DISK FORMAT '
F:\ORACLE\BACKUP\BAK_%U ' ;
- BACKUP DATABASE SKIP INACCESSIBLE
- PLUS ARCHIVELOG FILESPERSET 20
- DELETE ALL INPUT;
- RELEASE CHANNEL C1;
- }
- ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
- CROSSCHECK BACKUPSET;
- DELETE NOPROMPT OBSOLETE;
Save to F: \ oracle \ script \ backup \ db_fullbak_jssbook.rman.
Tip:
The CONFIGURE command in the first few lines can also be executed in addition to the batch processing script. It only needs to be executed once, because all CONFIGURE configurations will be saved to the control file of the target database, it will always be valid if no one changes it.
The above commands are mentioned in the previous chapters. If you look at your eyes, go back and read the previous content. The command is known, and several parameters may not understand its meaning.
For example, do not worry about the skip inaccessible parameter in the BACKUP command ...... Outside ...... Outside and outside ...... Let's take a look at the notes. You don't have to shake the kitchen knife around. You, you, and you, don't come here, I can't say it.) en, seeing everyone so devout, I will disclose this part of content in advance.
The above content is an introduction to Oracle's actual RMAN backup. I hope you will have some gains.