1.创建备份集

  1. 1.创建自定义路径表空间备份
  2. RMAN> backup as backupset format '/opt/oracle/df_%d_%s_%p.bkc' tablespace users;
  3. RMAN> backup tablespace fixf:system;
  4. 设置备份集分片大小
  5. RMAN> backup as backupset format '/opt/oracle/df_%d_%s_%p.bkc' tablespace users section size=300M;
  6. 2.创建自定义路径数据库备份
  7. RMAN> backup as backupset format '/opt/oracle/df_%d_%s_%p.bkc' database;
  8. 3.自定义标识备份
  9. backup tag 'full_db_bkp' format '/u01/backup/db_%U' database;
  10. 创建全库备份加归档日志
  11. BACKUP DATABASE PLUS ARCHIVELOG
  12. 创建全库备份加归档日志删除已归档日志
  13. BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
  14. 必须在发出以下CONFIGURE 命令后,才能按上述方式进行备份:
  15. CONFIGURE DEFAULT DEVICE TYPE TO disk;
  16. CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;
  17. CONFIGURE CONTROLFILE AUTOBACKUP ON;
  18. 为数据库中所有数据文件和控制文件的以前的映像副本创建备份
  19. RMAN> BACKUP COPY OF DATABASE;
  20. 备份users表空间及控制文件,归档日志
  21. backup tablespace users include current controlfile plus archivelog;
  22. backup datafile 1 plus archivelog;

1.2 备份归档日志

  1. backup archivelog all delete input;
  2. backup archivelog from sequence 353 delete input;
  3. backup archivelog not backed up 3 times;
  4. backup archivelog from time 'sysdate-3';
  5. backup archivelog until time 'sysdate -2' delete all input;

1.3备份备份集

  1. backup backupset all;
  2. backup backupset all format='/opt/oracle/back/backup_%U.BAK' TAG='backup of backupsets' channel 'ora_disk';
  3. backup backupset completed before 'sysdate-2';
  4. backup backupset complete before 'sysdate-2' delete input; 备份最近2天的所有备份集
  5. backup backup set complet after 'sysdate-2' delete input;备份2天前的所有备份集,并删除已经备份的备份集

1.4备份归档数据库和归档重做日志

  1. backup database plus archivelog;

2.设置备份运行指定的持续时间

此时间段过后数据库取消备份

  1. backup duration 00:30 database;

3.设置备份期间i/o平均分布,持续时间的的各个时间点上

  1. backup duration 00:30 minimize load database;平均性能
  2. backup duration 00:30 minimize time database;全速备份(默认值)

4.备份时指定保留日期

  1. backup database keep forever;永久保留 ----需要恢复目录------永久保存不能放在控制文件
  2. backup database format '/opt/oracle/back/%U' keep until time='sysdate+180' tag keep_backup;
  3. backup database format '/opt/oracle/back/%U' keep until time='sysdate+180' restore point gold_copy;

5.备份被configure参数指定排除之外的数据

  1. RMAN> backup database noexclude keep forever tag='test_backup';

6.备份时跳过脱机,不可访问,只读的数据文件

  1. backup database skip readonly;
  2. backup database skip offline;
  3. backup database skip inaccessible;
  4. backup database skip readonly skip offline skip inaccessible;

7.强制备份,备份所有数据文件

  1. backup database fore;

8.只备份新添加的数据文件

  1. backup database not backup up;

9.备份指定时间周期内没有被备份的数据文件

  1. backup database not backed up since time='sysdate -2';

10.备份至少备份2次的归档日志,删除已经备份2次的归档日志

  1. RMAN> backup as compressed backupset database plus archivelog not backed up 2
  2. times delete input;

11.检查逻辑损坏块

  1. backup check logical database;检查坏块同时备份数据
  2. backup avlidate check logical database;检查坏块不备份数据

12.备份控制文件

  1. RMAN> backup current controlfile; 备份控制文件
  2. spfile和控制文件自动备份:
  3. CONFIGURE CONTROLFILE AUTOBACKUP OFF;
  4. CONFIGURE CONTROLFILE AUTOBACKUP ON;
  5. 设置自动备份的存储位置:
  6. configure controlfile autobackup format for device type disk to '/u01/backup/ctl_%F';
  7. configure controlfile autobackup format for device type disk clear;

13.备份映像副本

  1. backup as copy database;
  2. list copy;还可以显示归档日志文件
  3. backup as copy datafile 4;
  4. backup as copy datafile 4 format '/u01/backup/user01.bak'

12.
2.管理备份:报告

  1. LIST:显示资料档案库中记录的有关备份集、代理副本和映像副本的信息
  2. REPORT:生成资料档案库的详细分析信息
  3. REPORT NEED BACKUP:列出需要备份的所有数据文件
  4. REPORT OBSOLETE:标识按照备份保留策略不再需要的文件

管理备份:动态性能视图

  1. V$BACKUP_SET:创建的备份集
  2. V$BACKUP_PIECE:存在的备份片段
  3. V$DATAFILE_COPY:磁盘上的数据文件副本
  4. V$BACKUP_FILES:有关创建备份时所创建的所有
  5. 文件的信息

管理备份:交叉检查和删除

  1. CROSSCHECK:针对介质(如磁盘或磁带)验证在RMAN 资料档案库中记录的备份和副本的状态
  2. DELETE EXPIRED:只删除资料档案库中状态为EXPIRED 的文件
  3. DELETE OBSOLETE:删除不再需要的备份