#!/bin/bashbackup_dir=/oracle/backuplog_file= $ORACLE _base/admin/$ORACLE _sid/cold_backup_$oracle_sid.logecho "Backuping cold backup" > $log _filedata>> $log _filesqlplus -s / As sysdba <<eof >> $log _fileset pagesize 0 linesize 1000 feedback off heading offspool file_copy_$oracle_sid.shselect ' cp ' | | name | | ' $backup _dir/' from v\ $controlfile;select ' cp ' | | file_name| | ' $backup _dir/' from dba_data_files;select ' cp ' | | member| | ' $backup _dir/' from v\ $logfile; spool offshutdown immediate;! bash file_copy_$oracle_sid.shstartupexit; eofrm -r file_copy_$oracle_sid.shif [ -e $ORACLE _home/dbs/init$oracle_sid.ora ] thencp $ORACLE _home/dbs/init$oracle_sid.ora $backup _dir/fiif [ -e $ORACLE _home/dbs/ spfile$oracle_sid.ora ]then#cp $ORACLe_home/dbs/spfile$oracle_sid.ora $backup _dir/fiif [ -e $ORACLE _home/dbs/orapw$oracle_sid ]then#cp $ORACLE _home/dbs/orapw$oracle_sid $backup _dir/fiecho "cold backup Finished. " >> $log _filedata>> $log _file
PS: Source "Linux-based Oracle database Management", the code is extensible, the current script is relatively single
Full-Library cold backup of shell scripts