There is a program that performs cold and hot backups of Oracle, and it is currently being used by hundreds of companies around the world -- oraback.sh. It is written in the Bourne shell, which is compatible with every Unix system. By using GNU's config.guess script, the list of Unix platforms that it runs on is perhaps limitless. The only thing that oraback.sh assumes is that the oratab file is properly configured; by default, oraback.sh automatically backs up every instance listed there. Oraback.sh supports these features:
$ oraback.sh To back up one or more instances, run it with those ORACLE_SIDs as arguments: $ oraback.sh ORACLE SID1 ORACLE SIDn To schedule a backup for the time specified in oraback.conf (described later in this section), run it with the at argument: $ oraback.sh at You may also combine these arguments together: $ oraback.sh at ORACLE SID1 ORACLE SIDn to specify both a backup time and the instances to be backed up. Installing oraback.shTo install oraback.sh, first put oraback.sh, config.guess, and localpath.sh in one directory, then check the following values in the site-specific section at the top of the script. They must be changed to fit the environment.
Configuring and customizing oraback.shOraback.conf is the main configuration file for oraback.sh. A normal oraback.conf file contains a hostname.master line that specifies several options such as which users are authorized to perform the backup, what backup device should be used, and on what days/times and cold/hot backup should be performed. If you specify oraback.sh with the at argument, it is the hostname.master line that oraback.sh uses to find the dates and times to run the backups. The hostname.master line is described below.hostname.master:[skip]:Cold Day:Cold Time:Hot Time:[tape device]:users:Parallelism:Backup Dir:Y::user ids: The above fields are described below:
Poststart(){
Deciding what or if to backupBefore actually running the backup, oraback.sh checks oraback.conf to determine:
$ oraback.sh
$ oraback.sh ORACLE_SID1 ORACLE_SIDn
$ oraback.sh at
Deciding where and how to back upOraback.sh then checks the hostname.master line in oraback.conf to find out if: (a) there is a tape device in field 6. If so, it labels the tape, making sure the no-rewind device is being used; and (b) there is a number in field 8. If so, it will perform that many simultaneous copies of database files.Next, oraback.sh asks Oracle questions that will determine how (or if) the SID will be backed up. It asks if
If it’s a hot backupIf the instance is online, logs are on, and the instance is not excluded from hot backups, then the script:
The script supports simultaneous copying of individual data files to dramatically increase the speed of the backup. Depending on how many files there are per tablespace, there may be one or more tablespaces in backup mode at once. This is done in order to perform the number of concurrent file copies (using dd) that are specified in field 8 of oraback.conf, if you are using this feature. After all data files are backed upNext, the script forces a checkpoint and archive log switch, which causes the online redo log to be sent to an archived redo log. It should be noted that it forces a log switch using the command alter sytem archive log current, instead of the older alter system switch logfile. The reason for this is that switching log files does just that, switches the log file and immediately returns the svrmgr prompt. The archive log current command waits until the copy of the old redo log to its archived location is done before it returns the prompt. This is because the next thing the script is going to do is to copy this archived redo log to the backup location for safekeeping. If we used the old command, we might by copying it from the archived log location while it is being created. That way we are assured that the file we are copying is stable.The script then backs up the control files to disk using both svrmgr and a manual copy. The manual copy is just for the paranoid; it's not a supported method of backing up the control file . Finally, the script makes copies of the essential redo logs and compresses them. (Essential logs are those that span the time of the backup.) If the backup device is a tape, it then backs up all files that were sent to disk to the tape device. If it’s a cold backupIf the instance is offline, oraback.sh only needs to copy the data files to the backup device. The script then backs up the control files and redo logs the same way it does during a hot backup. This is perhaps the only time that manually copying the control files and online redo logs does any good. That's because one could use these files to do a restore of the database to this point, without it ever knowing what happened. To do that, all the control files and online redo logs would be needed.Special casesIf the instance is online, but archiving is off, oraback.sh checks oraback.conf for a line that reads:HOST:ORACLE_SID:NOARCHIVELOG:[offline|nohotbackups] If that line is not found, oraback.sh complains and sends you mail. That is because archiving must be on in order to do hot backups. If the line is found, it looks for the word offline on that same line. This tells oraback.sh that this instance is not supposed to have archive logs running, and it should always do an offline, or cold, backup of this instance. If it sees the word offline, oraback.sh shuts down the instance, performs a cold backup, and then restarts the instance. (This is one of the ways to customize oraback.sh for different instances.) If the instance is online, oraback.sh also looks for a line in oraback.conf that reads: HOST:ORACLE_SID:::nohotbackup This tells oraback.sh that although ORACLE_SID qualifies for a hot backup (it has archiving on), oraback.sh should not do hot backups of this instance. This is best suited for a development database, where the weekly cold backup is sufficient. If this line is found, the script skips this instance when performing a hot backup. Customizing backups of an instanceIf there is an instance that will not run archiving or hot backups, put a line in oraback.conf that starts with:hostname:ORACLE_SID::::
Testing Oraback.shFor testing, select a small instance and run the following command as Oracle:$ /usr/local/bin/oraback.sh <instance> Be aware that if the word offline is in
oraback.conf, or if the day that is specified for cold backups is today,
the instance will be shut down!
Using Oraback.shThe best way to use this program is to have one single oraback.conf file that is NFS-mounted or shared to all Oracle systems. That way, all cron or at entries can run at 15:00, and backup configuration changes (system-wide or otherwise) can be made by editing one file. For example, to cause all Oracle backups to be skipped tonight, instead of having to edit a number of cron or at entries, edit this one file before 15:00. That way, it will see the word skip in there and not run backups that evening. (It will, however, take this word out so backups will run tomorrow night.)Set the SUCCESSMAIL flag to Y, to be mailed every time oraback.sh backup runs, successful or otherwise. That allows a quick email check in the morning to see that all backups ran successful. Simply check the subject line, since it will say ERROR if oraback.sh had any kind of errors. |