RMAN 中所有的备份操作,都是通过 BACKUP 命令(指创建备份集方式的备份)进行的,对于比较简单的备份需求,甚至只需要执行一条命令,下面分别演示通过BACKUP命令进行不同级别的备份。
只需要一条命令,如下所示:
RMAN>BACKUP DATABASE;
Starting backup at 29-MAR-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=F:\ORACLE\ORADATA\JSSBOOK\SYSTEM01.DBF
input datafile fno=00002 name=F:\ORACLE\ORADATA\JSSBOOK\UNDOTBS01.DBF
input datafile fno=00003 name=F:\ORACLE\ORADATA\JSSBOOK\SYSAUX01.DBF
input datafile fno=00005 name=F:\ORACLE\ORADATA\JSSBOOK\SCOTT_TBS01.DBF
input datafile fno=00004 name=F:\ORACLE\ORADATA\JSSBOOK\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\08KB53MK_1_1 tag=TAG2009032
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\09KB53O2_1_1 tag=TAG2009032
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAR-09执行上述命令后,将对目标数据库中的所有数据文件进行备份,如果你对RMAN的返回信息看得足够认真,你应该已经发现,该备份集生成了两个备份片段:一个存储数据文件,另一个存储控制文件和SPFILE(服务器端初始化参数文件),都被保存到Oracle软件的安装目录下,这是因为没有为备份集指定存储路径,默认情况下就会存储到Oracle软件的安装目录中。
如果是真正的备份操作,你肯定希望能够指定备份集的存储位置,没问题,最简单的方式是在执行BACKUP命令时,指定 FORMAT 参数来自定义备份片段的路径和命令规则,比如:
RMAN>BACKUP DATABASE FORMAT 'f:\oracle\backup\bak_%U' ;
Starting backup at 29-MAR-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=F:\ORACLE\ORADATA\JSSBOOK\SYSTEM01.DBF
input datafile fno=00002 name=F:\ORACLE\ORADATA\JSSBOOK\UNDOTBS01.DBF
input datafile fno=00003 name=F:\ORACLE\ORADATA\JSSBOOK\SYSAUX01.DBF
input datafile fno=00005 name=F:\ORACLE\ORADATA\JSSBOOK\SCOTT_TBS01.DBF
input datafile fno=00004 name=F:\ORACLE\ORADATA\JSSBOOK\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\BACKUP\BAK_0BKB55PM_1_1 tag=TAG20090329T163917 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\BACKUP\BAK_0CKB55R3_1_1 tag=TAG20090329T163917 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 29-MAR-09如果想查看创建的全库备份,可以通过 LIST 命令来查看:
RMAN> LIST BACKUP OF DATABASE;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8 Full 294.10M DISK 00:00:36 29-MAR-09
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20090329T163917
Piece Name: F:\ORACLE\BACKUP\BAK_0BKB55PM_1_1
List of Datafiles in backup set 8
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 644090 29-MAR-09 F:\ORACLE\ORADATA\JSSBOOK\SYSTEM01.DBF
2 Full 644090 29-MAR-09 F:\ORACLE\ORADATA\JSSBOOK\UNDOTBS01.DBF
3 Full 644090 29-MAR-09 F:\ORACLE\ORADATA\JSSBOOK\SYSAUX01.DBF
4 Full 644090 29-MAR-09 F:\ORACLE\ORADATA\JSSBOOK\USERS01.DBF
5 Full 644090 29-MAR-09 F:\ORACLE\ORADATA\JSSBOOK\SCOTT_TBS01.DBF注意看返回结果的加粗部分,这部分内容说明该备份集对应的备份片段保存位置。
只要实例启动并处于加载状态,无论数据库是否打开,都可以在RMAN中对表空间进行备份。例如,备份USERS表空间(因为它最小,操作最方便,因此用它来做演示):
RMAN> BACKUP TABLESPACE USERS;
Starting backup at 29-MAR-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=F:\ORACLE\ORADATA\JSSBOOK\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 29-MAR-09
channel ORA_DISK_1: finished piece 1 at 29-MAR-09
piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0DKB562D_1_1 tag=TAG20090329T164357 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-MAR-09同样,我们在使用 BACKUP TABLESPACE 命令也可以通过显式指定 FORMAT 参数自定义备份片段名称。
我们再通过LIST BACKUP命令查看一下备份:
你会发现输出的信息中显示,USERS表空间存在两份备份(因为前面刚执行过全库备份嘛),不妨借此机会学习删除的操作,删除使用DELETE命令,下例使用DELETE命令删除指定的 BACKUPSET :
RMAN> DELETE BACKUPSET 10;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------ ------- --- --- ----------- ----------- ----------
10 10 1 1 AVAILABLE DISK F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0DKB562D_1_1
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=F:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\0DKB562D_1_1 recid=10 stamp=682793037
Deleted 1 objects执行DELETE命令时,默认情况下会给出是否确认删除的提示信息,以避免误操作。如果希望跳过提示的话(比如用后台脚本方式执行,无处确认),那么可以在执行DELETE命令时附加NOPROMPT子句,这里不演示了,感兴趣的朋友可以自行测试。
相关视频
相关阅读 数据库流行度排行2019年9月 数据库排行榜2019年最新版fifa online4数据库大全 fifa online4球员数据库在哪myeclipse怎么连接到数据库 myeclipse连接到数据库方法PLSQL Developer怎么导出数据库PLSQL Developer配置Oralce11g连接plsql developer怎么使用 plsql developer使用教程plsql developer怎么连接数据库 plsql developer连接数据库教程mysql数据库root密码忘记的修改方法
热门文章 oracle10g安装图解(wi
最新文章
数据库流行度排行2019oracle10g安装图解(wi
SQL2008全部数据导出导入两种方法SQL2005新建复制“找不到存储过程 错误:28Dos远程登录mysql数据库详细图文教程mysql怎么开启远程登录功能
人气排行 mysql自动定时备份数据库的最佳方法-支持wiVisual Foxpro 6.0安装向导图文教程SQL Server 2008 安装图文教程SQL2008全部数据导出导入两种方法SQL 2000/2005/2008 的收缩日志方法,和清理mysql出 Can't connect to MySQL server onoracle10g安装图解(win7)sql2005安装图解_(sql server2005)安装教程
查看所有0条评论>>