⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oraback.html

📁 oracle数据库备份脚本
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</dl><font face="Arial,Helvetica">Using these functions is very simple.&nbsp;For example, to restart orasrv after an instance is restarted (with a scriptcalled rc.orasrv.sh,) change the Poststart function to read:</font><p><font face="Arial,Helvetica">Poststart(){</font><br><font face="Arial,Helvetica">rc.orasrv.sh</font><br><font face="Arial,Helvetica">}</font><br>&nbsp;<h2><font face="Arial,Helvetica">Deciding what or if to backup</font></h2><font face="Arial,Helvetica">Before actually running the backup, oraback.shchecks oraback.conf to determine:</font><ul><li><font face="Arial,Helvetica">Whether the user running the backup is oracle,or is a valid user (listed in field 7 of oraback.conf).&nbsp; If the userid running the backup is not a valid user, the script will not continue.&nbsp;</font></li><li><font face="Arial,Helvetica">If it is a valid user, oraback.sh then looksto see whether the word skip is in field 2.&nbsp; If so, it skips the backuponce, and removes the word skip from oraback.conf.&nbsp; (This allows aDBA to manually skip tonight's backup, but does not allow the DBA to accidentallydisable backups forever.)</font></li></ul><font face="Arial,Helvetica">The script then does one of the following,depending on which arguments (if any) it receives:</font><br>&nbsp;<ul><li><font face="Arial,Helvetica">It backs up everything</font></li></ul><font face="Arial,Helvetica">If given no arguments, it performs a backupof all instances listed in Oracle's oratab file.</font><br><font face="Arial,Helvetica">$ oraback.sh&nbsp;</font><br>&nbsp;<ul><li><font face="Arial,Helvetica">It backs up selected instances</font></li></ul><font face="Arial,Helvetica">If given one or more instance names (ORACLE_SIDs,or SIDs for short) as arguments, the script performs a backup of each ofthem.</font><br><font face="Arial,Helvetica">$ oraback.sh ORACLE_SID1 ORACLE_SIDn&nbsp;</font><ul><li><font face="Arial,Helvetica">It schedules a backup for later</font></li></ul><font face="Arial,Helvetica">If called with at as an argument (this iswhat would be in cron), the script checks oraback.conf to see whether theday in field 3 (the cold backup day field) is today.&nbsp; If so, it setsthe variable $TIME to the time in field 4.&nbsp; If not, it sets $TIMEto the time in field 5. The script then schedules an at job that will runoraback.sh at the time specified by $TIME.</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">$ oraback.sh at&nbsp;</font><br><font face="Arial,Helvetica"></font>&nbsp;<h2><font face="Arial,Helvetica">Deciding where and how to back up</font></h2><font face="Arial,Helvetica">Oraback.sh then checks the hostname.masterline in oraback.conf to find out if: (a) there is a tape device in field6.&nbsp; If so, it labels the tape, making sure the no-rewind device isbeing used; and (b) there is a number in field 8.&nbsp; If so, it willperform that many simultaneous copies of database files.</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">Next, oraback.sh asks Oracle questionsthat will determine how (or if) the SID will be backed up.&nbsp; It asksif</font><ul><li><font face="Arial,Helvetica">The instance is online.&nbsp; If so, oraback.shmakes a set of configuration files needed later</font></li><li><font face="Arial,Helvetica">Archiving is running</font></li><li><font face="Arial,Helvetica">The instance is excluded from hot backup</font></li><li><font face="Arial,Helvetica">This is a cold backup.&nbsp; If so, it shutsdown the instance.</font></li></ul><font face="Arial,Helvetica">The script assumes that all instances wanthot backups (though you may specify cold backups), which requires automaticarchiving of redo logs.&nbsp; Oraback.sh warns if any instances do nothave automatic archiving turned on.&nbsp; It continues to complain untilthis situation is corrected or oraback.conf is customized for that instance.&nbsp;(You do this by editing oraback.conf.)</font><h3><font face="Arial,Helvetica">If it抯 a hot backup</font></h3><font face="Arial,Helvetica">If the instance is online, logs are on, andthe instance is not excluded from hot backups, then the script:</font><ol><li><font face="Arial,Helvetica">Puts each tablespace into backup mode by usingthe svrmgrl command begin backup.&nbsp;</font></li><li><font face="Arial,Helvetica">Copies that tablespace's files to the backupdevice</font></li><li><font face="Arial,Helvetica">Takes the tablespace out of backup mode withthe svrmgrl command end backup&nbsp;</font></li></ol><font face="Arial,Helvetica">These three steps are the core of the hotbackup.&nbsp; While the tablespace is in backup mode, the files can besafely backed up.</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">The script supports simultaneous copyingof individual data files to dramatically increase the speed of the backup.&nbsp;Depending on how many files there are per tablespace, there may be oneor more tablespaces in backup mode at once.&nbsp; This is done in orderto perform the number of concurrent file copies (using dd) that are specifiedin field 8 of oraback.conf, if you are using this feature.</font><h3><font face="Arial,Helvetica">After all data files are backed up</font></h3><font face="Arial,Helvetica">Next, the script forces a checkpoint and archivelog switch, which causes the online redo log to be sent to an archivedredo log.&nbsp; It should be noted that it forces a log switch using thecommand alter sytem archive log current, instead of the older alter systemswitch logfile.&nbsp; The reason for this is that switching log files doesjust that, switches the log file and immediately returns the svrmgr prompt.&nbsp;The archive log current command waits until the copy of the old redo logto its archived location is done before it returns the prompt.&nbsp; Thisis because the next thing the script is going to do is to copy this archivedredo log to the backup location for safekeeping.&nbsp; If we used the oldcommand, we might by copying it from the archived log location while itis being created.&nbsp; That way we are assured that the file we are copyingis stable.</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">The script then backs up the control filesto disk using both svrmgr and a manual copy.&nbsp; The manual copy is justfor the paranoid; it's not a supported method of backing up the controlfile .&nbsp; Finally, the script makes copies of the essential redo logsand compresses them.&nbsp; (Essential logs are those that span the timeof the backup.)&nbsp; If the backup device is a tape, it then backs upall files that were sent to disk to the tape device.</font><h3><font face="Arial,Helvetica">If it抯 a cold backup</font></h3><font face="Arial,Helvetica">If the instance is offline, oraback.sh onlyneeds to copy the data files to the backup device.&nbsp; The script thenbacks up the control files and redo logs the same way it does during ahot backup.&nbsp; This is perhaps the only time that manually copying thecontrol files and online redo logs does any good.&nbsp; That's becauseone could use these files to do a restore of the database to this point,without it ever knowing what happened.&nbsp; To do that, all the controlfiles and online redo logs would be needed.</font><h3><font face="Arial,Helvetica">Special cases</font></h3><font face="Arial,Helvetica">If the instance is online, but archiving isoff, oraback.sh checks oraback.conf for a line that reads:</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">HOST:ORACLE_SID:NOARCHIVELOG:[offline|nohotbackups]</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">If that line is not found, oraback.sh complainsand sends you mail.&nbsp; That is because archiving must be on in orderto do hot backups.&nbsp; If the line is found, it looks for the word offlineon that same line.&nbsp; This tells oraback.sh that this instance is notsupposed to have archive logs running, and it should always do an offline,or cold, backup of this instance.&nbsp; If it sees the word offline, oraback.shshuts down the instance, performs a cold backup, and then restarts theinstance.&nbsp; (This is one of the ways to customize oraback.sh for differentinstances.)</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">If the instance is online, oraback.sh alsolooks for a line in oraback.conf that reads:</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">HOST:ORACLE_SID:::nohotbackup</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">This tells oraback.sh that although ORACLE_SIDqualifies for a hot backup (it has archiving on), oraback.sh should notdo hot backups of this instance.&nbsp; This is best suited for a developmentdatabase, where the weekly cold backup is sufficient.&nbsp; If this lineis found, the script skips this instance when performing a hot backup.</font><h3><font face="Arial,Helvetica">Customizing backups of an instance</font></h3><font face="Arial,Helvetica">If there is an instance that will not runarchiving or hot backups, put a line in oraback.conf that starts with:</font><br><font face="Arial,Helvetica">hostname:ORACLE_SID::::</font><ol><li><font face="Arial,Helvetica">Put NOARCHIVELOG in field 3 if the instancedoes not use archiving.</font></li><li><font face="Arial,Helvetica">Put offline in field 4 if the instance doesnot use archiving, and oraback.sh should do a cold backup done every time.</font></li><li><font face="Arial,Helvetica">Put nohotbackups in field 5 to skip hot backupsfor this instance.&nbsp; (It will only be backed up when cold backups run).</font></li></ol><h3><font face="Arial,Helvetica">Testing Oraback.sh</font></h3><font face="Arial,Helvetica">For testing, select a small instance and runthe following command as Oracle:</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">$ /usr/local/bin/oraback.sh &lt;instance></font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">Be aware that if the word offline is inoraback.conf, or if the day that is specified for cold backups is today,the instance will be shut down!</font><br><font face="Arial,Helvetica">If this test functions properly, put anentry in Oracle's cron or in the at system.&nbsp; Add a cron entry thatcontains the command /usr/local/bin/oraback.sh at, schedule to run at around12:00.&nbsp; It checks the oraback.conf and schedules an at job that willperform the backup.</font><h3><font face="Arial,Helvetica">Using Oraback.sh</font></h3><font face="Arial,Helvetica">The best way to use this program is to haveone single oraback.conf file that is NFS-mounted or shared to all Oraclesystems.&nbsp; That way, all cron or at entries can run at 15:00, and backupconfiguration changes (system-wide or otherwise) can be made by editingone file.&nbsp; For example, to cause all Oracle backups to be skippedtonight, instead of having to edit a number of cron or at entries, editthis one file before 15:00.&nbsp; That way, it will see the word skip inthere and not run backups that evening.&nbsp; (It will, however, take thisword out so backups will run tomorrow night.)</font><font face="Arial,Helvetica"></font><p><font face="Arial,Helvetica">Set the SUCCESSMAIL flag to Y, to be mailedevery time oraback.sh backup runs, successful or otherwise.&nbsp; Thatallows a quick email check in the morning to see that all backups ran successful.&nbsp;Simply check the subject line, since it will say ERROR if oraback.sh hadany kind of errors.</font>&nbsp;</td></tr></table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -