RMAN常用备份脚本

1. 基本0的增量备份
create script. b_whole_inc0{
backup
incremental level 0 database
format '/bakup/rman/backup/orcl/db0_%d_%s_%p_%t'
tag = 'WHOLE_INC0';
}

2. 基本1的增量备份
create script. b_whole_inc1{
backup
incremental level 1 cumulative database
format '/bakup/rman/backup/orcl/db1_%d_%s_%p_%t'
tag='WHOLE_INC1';
}

3. 基本2的增量备份
create script. b_whole_inc2{
backup
incremental level 2 cumulative database
format '/bakup/rman/backup/orcl/db2_%d_%s_%p_%t'
tag='WHOLE_INC2';
}

4. 归档当前的重做日志组
create script. archive_log_current{
sql"ALTER SYSTEM ARCHIVE LOG CURRENT";
}

5. 备份前两天的归档日志
create script. b_archive_2days{
execute script. archive_log_current;
backup archivelog from time 'SYSDATE-2'
format '/bakup/rman/backup/orcl/ar_%d_%s_%p_%t';
}

6. 备份大前天的归档日志并删除
create script. archive_delete3{
execute script. archive_log_current;
backup archivelog from time 'SYSDATE-3' until time 'SYSDATE-2'
format '/bakup/rman/backup/orcl/ar_%d_%s_%p_%t'
delete input;
}

7. 备份类型为COPY
run{
   allocate channel d1 type disk;
   copy
   datafile 1 to '/bakup/rman/backup/orcl/system01.dbf.bak',
   datafile 2 to '/bakup/rman/backup/orcl/undotbs01.dbf.bak',
   datafile 3 to '/bakup/rman/backup/orcl/sysaux01.dbf.bak',
   datafile 4 to '/bakup/rman/backup/orcl/users01.dbf.bak',
   datafile 5 to '/bakup/rman/backup/orcl/example01.dbf.bak',
   datafile 6 to '/bakup/rman/backup/orcl/rmantbs01.dbf.bak',
   current controlfile to '/bakup/rman/backup/orcl/control_bakup.ctl';
}

or

run{
     backup as copy database;
}

8. 备份增量基本为0的数据库备份和所有的归档日志
run{
   allocate channel c1 type disk;
   backup incremental level 0 database
   format '/bakup/rman/backup/orcl/db_%d_%s_%p_%t'
   tag = 'WHOLE_INC0'
   archivelog all
   format '/bakup/rman/backup/orcl/ar_%d_%s_%p_%t'
   tag 'BACKUP_ARCHIVELOG_ALL';
}

你可能感兴趣的:(rman)