ORCLE 数据库备份与恢复之四:RMAN
2008-08-28 12:43:26 来源:WEB开发网或
$ rman catalogrman/rman targetuser/pwd>@db
3. 命令行接口
1、单个执行
RMAN> backup database;
2、运行一个命令块
RMAN> RUN {
2> copy datafile 10 to
3> '/oracle/prod/backup/prod_10.dbf';
4> }
3、运行存储在恢复目录中的脚本:
RMAN> RUN { EXECUTE SCRIPT backup_whole_db };
4、运行外部脚本:
$ rman catalog rman/rman target / @backup_db.rman
$ rman cmdfile=backup.rman msglog=backup.log
RMAN> @backup_db.rman
RMAN> RUN { @backup_db.rman }
如果在 cron 中执行,注意在脚本中设置正确的环境变量,例:
#set env
export ORACLE_HOME=/opt/oracle/product/9.2
export ORACLE_SID=test
export NLS_LANG="AMERICAN_AMERICA.zhs16gbk"
export PATH=$PATH:$ORACLE_HOME/bin rman cmdfile=backup_db.rman
4. 使用脚本
创建或者取代脚本:
RMAN> create script alloc_disk {
2> # Allocates one disk
3> allocate channel dev1 type disk;
4> setlimit channel dev1 kbytes 2097150 maxopenfiles 32 readrate 200;
5> }
RMAN> replace script rel_disk {
2> # releases disk
3> release channel dev1;
5> }
删除脚本:
RMAN> DELETE SCRIPT Level0Backup;
查看脚本:
RMAN> PRINT SCRIPT Level0Backup;
运行脚本:
RMAN> RUN { EXECUTE SCRIPT backup_whole_db };
赞助商链接