oracle之rman增量备份

1、差异性增量备份
backup incremental level 0 database format ‘c:\rman\L0_%U.bak’;
backup incremental level 1 database format ‘c:\rman\L1C_%U.bak’;

2、累积性增量备份
backup incremental level 0 database format ‘c:\rman\L0_%U.bak’;
backup incremental level 1 cumulative database format ‘c:\rman\L1C_%U.bak’;

Note:差异性备份是同一级别不备份,而累积性备份是同一级别的也备份
备份的级别可以为0、1、2、3、4

3、启用/关闭oracle块更改跟踪
开启
alter database enable block change tracking using file
‘c:\oracle\product\10.2.0\admin\orcl\bdump\block_trace.txt‘
关闭
alter database disable block change tracking;

oracle之rman(2)

1、设置并发执行rman备份
1)手工配置
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup database format ‘c:\rman\d_%U_%p.bak’
tag=’xifenfei’;
}
2)参数中配置
configure device type disk parallelism 3 backup type to backupset;
backup database format ‘c:\rman\d_%U.bak’ tag=’xifenfei’;

2、设置备份文件大小
run{ allocate channel c1 type disk maxpiecesize 100m;
backup database format ‘c:\rman\test_%U_%p.bak’ filesperset 2 maxsetsize 500m;}
note:maxpiecesize–单个备份文件大小
filesperset–一个backset中含有的datafile的数量
maxsetsize–backset的大小

3、备份控制文件
1)配置自动备份
configure controlfile autobackup on;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
DEVICE TYPE DISK TO ‘c:\rman\cl_%F.ctl’;
2)备份时顺带备份
backup datafile 5 format ‘c:\rman\d_%U.bak’
include current controlfile;

4、一次备份多份(最多四份)
1)直接指定
backup copies 2 datafile 5 format
‘c:\rman\%U.bak’,’c:\temp\%U.bak’;
2)配置文件中指定
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 2;
backup datafile 5 format ‘c:\temp\t_%U.bak’,’c:\rman\t_%U.bak’;

oracle 之rman备份数据库

1、备份整个数据库
backup database format ‘c:\rman\all_%U.bak’;
2、备份表空间
backup tablespace abc format ‘c:\rman\t_%U.bak’;
3、备份数据文件
1)backup datafile 5 format ‘c:\rman\d_%U.bak’;
2)backup datafile ‘C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ABC.DBF’
format ‘c:\rman\d_%U.bak’;
4、备份控制文件
backup current controlfile format ‘c:\rman\ctr_%U.ctl’;
5、备份数据文件同时备份控制文件
backup datafile 5 format ‘c:\rman\d_c_%U.bak’
include current controlfile;
6、备份spfile文件
backup spfile format ‘c:\rman\sp_%U.sp’;
7、备份日志文件
backup archivelog sequence between 38 and 41 format ‘c:\rman\ar_%U.log’
delete all input(可选项,表示备份日志文件后,删除原来日志文件);
8、备份数据库和日志文件
backup database plus archivelog format ‘c:\rman \d_ar_%U.d_a’;
9、copy功能(相当于用户管理备份)
backup as copy database format ‘c:\rman\%U.cy’;
copy datafile 5 to ‘c:\rman\d_%U.cy’;
note:backup as copy可以备份整个数据库
copy只能备份current controlfile、datafile、tablespace等,这个数据库不支持

oracle之用户管理备份

一、冷备份
1、shutdown immedate
2、copy datafile/redofile/contorfile/spfile(pfile)/pwdfile
3、startup

--备份脚本(没备份spfile/pwdfile等文件)
sqlplus / as sysdba
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200
define dir='c:\user'
define ws='c:\user\user.sql'
spool &ws
select 'host copy '||name|| ' &dir' from v$datafile order by 1;
select 'host copy '||name|| ' &dir' from v$controlfile order by 1;
select 'host copy '||name|| ' &dir' from v$tempfile order by 1;
select 'host copy '||member|| ' &dir' from v$logfile order by 1;
select 'host copy '||value' &dir' from v$parameter where name like '%spfile%';--backup spfile
spool off
shutdown immediate
@&ws
startup

二、热备份
1)备份表空间
alter tablespace tabalepsacename begin backup;
copy
alter tablespace tabalepsacename endbackup;
2)备份整个数据库
alter database begin backup;
copy
alter database end backup;

--脚本备份表空间
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200
define dir='c:\user'
define ws='c:\user\user.sql'
define ts=&tablespace
alter tablespace &ts begin backup;
spool &ws
select 'host copy '|| file_name || ' &dir' from dba_data_files where tablespace_name =UPPER('&ts');
spool off
@&ws
alter tablespace &ts end backup;
--脚本备份整个数据库
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200
define dir='c:\user'
define ws='c:\user\user.sql'
alter database begin backup;
spool &ws
select 'host copy '||name|| ' &dir' from v$datafile order by 1;
select 'host copy '||name|| ' &dir' from v$controlfile order by 1;
select 'host copy '||name|| ' &dir' from v$tempfile order by 1;
select 'host copy '||member|| ' &dir' from v$logfile order by 1;
select 'host copy '||value' &dir' from v$parameter where name like '%spfile%';--backup spfile
spool off
@&ws
alter database end backup; 

3)备份数据文件
alter datafile 4 begin backup;
copy
alter datafile 4 end backup;

三、查看backup状态
select * from v$backup;

oracle之rman(1)

1、连接rman
1)nocatalog模式访问
rman target sys/xifenfei@orcl nocatalog
2)启用日志文件
rman target sys/xifenfei@orcl nocatalog append log ‘c:\rman.log’

2、查看rman configure 信息
所有信息 show all;
查看相关信息:show device type;

3、rman参数设置
1)设置参数
configure controlfile autobackup off;
2)恢复为默认参数
configure controlfile autobackup clear;