Oracle备份(三)------热备

--connect database

connect sys/oracle;

--archive

alter system archive log current;

--此处可以多次归档

alter system archive log current;

--热备数据文件

alter database begin backup;

拷贝所有的datafile到备份目录

cd /var/oracle/oracle/oradata/traveldb

cp *.dbf /home/oracle/hotbak/

ls

alterdatabaseendbackup;

--热备表空间

altertablespacetablespace_namebeginbackup;

拷贝tablespace_name表空间的数据文件到备份目录

altertablespacetablespace_nameendbackup;

----热备控制文件

alter database backup controlfile to '/home/oracle/hotbak/ctlbak.ctl'; --控制文件的完整备份

alter database backupcontrolfile to trace as '/home/oracle/hotbak/ctlbak.trc'

--热备参数文件

createpfilefromspfile;

create pfile = '/home/oracle/hotbak/pfile' from spfile;

临时表空间的数据文件、日志文件不需要备份

--查看临时表空间selecttablespace_namefromdba_temp_files;

--热备脚本

SQL>hocat/tmp/tmphotbak.sql;

setfeedbackoff

setheadingoff

setverifyoff

settrimspooloff

setpagesize 0

setlinesize 200

define dir='/u01/app/oracle/hotbak'

define script='/tmp/hotbak.sql'

spool&script

select'ho cp '||name||' &dir'fromv$datafile;

spooloff

alterdatabasebeginbackup;

start&script

alterdatabaseendbackup;

alterdatabasebackupcontrolfileto'&dir/controlbak.ctl';

createpfile='&dir/initorcl.ora'fromspfile;

SQL>start/tmp/tmphotbak.sql;--执行该脚本即可对数据库进行热备


你可能感兴趣的:(oracle)