shell脚本之全库热备份

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本之全库热备份相关的知识,希望对你有一定的参考价值。

#!/bin/bash
backup_dir=/oracle/backup
log_file=$ORACLE_BASE/admin/$ORACLE_SID/hold_backup_$ORACLE_SID.log
echo "Backuping cold backup..." >$log_file
data>>$log_file

sqlplus -s / as sysdba <<EOF >>$log_file
alter database backup controlfile to '$backup_dir/backup_controlfile.ctl';
set pagesize 0 linesize 1000 feedback off heading off
column tablespace_name noprin
column sortorder noprin
column textout format a120

spool hold_backup_$ORACLE_SID.sql

select tablespace_name,'1' sortorder,'alter tablespace '||tablespace_name||' begin backup ;' textout
from dba_data_files
union
select tablespace_name ,'2' sortorder,'host cp'||file_name||' '||' $backup_dir' textout
from dba_data_files
union
select tablespace_name,'3' sortorder,'alter tablespace '|| tablespace_name ||' end backup ;' textout
from dba_data_files
order by tablespace_name,sortorder,textout;

select 'alter system archive log current;' from dual;
spool off;


@hold_backup_$ORACLE_SID.sql

exit
EOF

rm -f hold_backup_$ORACLE_SID.sql
echo "Hot backup finished.">>$log_file



PS:同全库冷备份

以上是关于shell脚本之全库热备份的主要内容,如果未能解决你的问题,请参考以下文章

从库热备份的脚本

MySql DUMP 自动备份数据库 Shell 脚本

MySql DUMP 自动备份数据库 Shell 脚本

MySql DUMP 自动备份数据库 Shell 脚本

mysql怎么操作备份

Linux系统shell脚本之mysql备份