Oracle rman 脚本

1、shell脚本
1)vi rman_backup.cmd
#rman_backup.cmd
connect target /
run
{
  allocate channel d1 device type disk;
  backup database format='/u01/backup/%T_%d_%s.bak' plus archivelog;
  sql 'alter system archive log current';
  backup current controlfile format='/u01/backup/%T_%d_%s.ctl';
  release channel d1;
}


2)vi rman_backup.sh
#!/bin/bash
rman @'/u01/rman_backup.cmd'


3)sh rman_backup.sh
[oracle@serv11 u01]$ sh rman_backup.sh


2、rman脚本
1)vi backup.rman
#backup.rman
run
{
  allocate channel d1 device type disk;
  backup database format='/u01/backup/%T_%d_%s.bak' plus archivelog;
  sql 'alter system archive log current';
  backup current controlfile format='/u01/backup/%T_%d_%s.ctl';
  release channel d1;
  sql 'alter system archive log current';
}


2)在rman中手动调用脚本
RMAN> @/u01/backup.rman

注意:语句后面不能加分号

原文地址:https://www.cnblogs.com/john2017/p/6364549.html