使用catalog的rman备份与恢复

一,创建catalog rman用户


二,创建存储脚本

来自于:基于catalog创建存储脚本

创建

创建全局脚本

RMAN> create global script global_full_backup
2> comment 'A script for full backup'
3> {
4> backup database plus archivelog tag='full0_db_backup';
5> delete obsolete;
6> }

注意“;”,每结束完整的语句要加分号

创建本地脚本

RMAN> create script full_backup
2> comment 'location script'
3> {
4> backup as compressed backupset database plus archivelog delete input
5> tag='full_db_backup';                       ---注意分号
6> delete obsolete;
7> }
created script full_backup

创建文本脚本

[oracle@hxy script]$ vi backup_ctl_spfile.src
{
  tag='ctl_spfile'
{
  allocate channel ch1 device type disk;
  backup current controlfile
  tag='ctl_spfile';
  release channel ch1;
}
一定要有{  }开始结束!!

然后再rman中执行

RMAN> create script ctl_spfile_bk from file '/home/oracle/script/backup_ctl_spfile.src';

script commands will be loaded from file /home/oracle/script/backup_ctl_spfile.src
created script ctl_spfile_bk

查看

查看回复目录中的脚本

RMAN> list all script names;

RMAN> list global script names;

查看脚本中的内容

RMAN> print script global_full_backup;
printing stored global script: global_full_backup
 {backup database plus archivelog tag='full0_db_backup';

delete obsolete;
}

将脚本中的内容转存到操作系统文件

RMAN> print script global_full_backup to file '/home/oracle/script/global_full_backup.src';

global script global_full_backup written to file /home/oracle/script/global_full_backup.src


RMAN> host;
[oracle@hxy ~]$ cd script/
[oracle@hxy script]$ ll
total 16
-rw-r--r-- 1 oracle oinstall 117 Feb 25 14:49 backup_ctl_spfile.src
-rw-r--r-- 1 oracle oinstall 105 Feb 23 13:39 full0.sh
-rw-r--r-- 1 oracle oinstall 250 Feb 23 14:39 full0.src
-rw-r--r-- 1 oracle oinstall  76 Feb 25 15:05 global_full_backup.src
[oracle@hxy script]$ cat global_full_backup.src 
 {backup database plus archivelog tag='full0_db_backup';
delete obsolete;

}

修改更新脚本

RMAN> replace global script global_full_backup
2> {
3>  backup as compressed backupset database plus archivelog
4>  tag='full_db_backup';
5>  delete obsolete;
6> }

replaced global script global_full_backup

从一个文件中更新一个脚本

1.在文件中写好脚本,注意加{}

2.在rman中执行

RMAN> replace script ctl_spfile_bk from file '/home/oracle/script/backup_ctl_spfile.src';

执行脚本

RMAN> run {
2>   execute script ctl_spfile_bk;
3> }
从远程直接执行脚本
[oracle@hxy ~]$ rlwrap rman target sys/oracle@orcl catalog rman/rman@rman_db script'ctl_spfile_bk'

删除脚本

RMAN> delete script global_full_backup;

来自:robison

 注意:使用EXECUTE SCRIPT, DELETE SCRIPT ,PRINT SCRIPT等命令时,如果一个本地的脚本未找到,则寻找全局的脚本来代替。

    因此应当注意命名规范,尽可能的不使用重名的脚本名,当DELETE SCRIPT 找不到本地脚本,而找到同样名字的全局脚本,则全局

    脚本被删除

三,基于catalog的备份

四,基于catalog的恢复

你可能感兴趣的:(使用catalog的rman备份与恢复)