Oralce备份与恢复(待完善)
一、物理备份
1.1 冷备(停机cp)
1.获取数据文件路径:select file_name from dba_data_files; 2.获取控制文件路径:select name from v$controlfile; 3.查询日志文件路径:select member from v$logfile; shutdown immediate; cp /u01/app/oracle/oradata/orcl/* /data/orcl_bak/ startup;
1.2 归档模式cp文件(热备)
-- 1.备份之前进行一次日志切换,将当下时间点之前的日志转储到归档日志中。 alter system switch logfile; -- 2.获取表空间物理文件路径。 select tablespace_name,file_name from dba_data_files; -- 3.以表空间为基本单位依次备份数据文件:先将表空间设置为backup状态,拷贝,最后还原; alter tablespace system begin backup; host cp /u01/app/oracle/oradata/orcl/system01.dbf /data/hot_bak/ alter tablespace system end backup; alter tablespace users begin backup; host cp /u01/app/oracle/oradata/orcl/users01.dbf /data/hot_bak/ alter tablespace users end backup; alter tablespace testtbs begin backup; host cp /u01/app/oracle/oradata/orcl/test01.dbf /data/hot_bak/ alter tablespace testtbs end backup; ... -- 4.备份控制文件 alter database backup controlfile to '/data/hot_bak/control.bak'; -- 5.归档当前的日志 alter system archive log current;