来自于:基于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;
}
从一个文件中更新一个脚本
1.在文件中写好脚本,注意加{}
2.在rman中执行
RMAN> replace script ctl_spfile_bk from file '/home/oracle/script/backup_ctl_spfile.src';
注意:使用EXECUTE SCRIPT, DELETE SCRIPT ,PRINT SCRIPT等命令时,如果一个本地的脚本未找到,则寻找全局的脚本来代替。
因此应当注意命名规范,尽可能的不使用重名的脚本名,当DELETE SCRIPT 找不到本地脚本,而找到同样名字的全局脚本,则全局
脚本被删除