1 database 必须运行在归档模式下
2 备份目录必须存在
C:\Documents and Settings\SKS>sqlplus /nolog
SQL*Plus: Release 10.1.0.2.0 - Production . 星期五 2月 27 11:20:33 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> conn
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
SQL> archive log list;
ORA-01012: not logged .
SQL> conn /as sysdba;
Connected.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest .line log sequence 50
Current log sequence 52
SQL> alter database archivelog;
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest .line log sequence 50
Next log sequence to archive 52
Current log sequence 52
SQL> alter database open;
C:\Documents and Settings\SKS>rman target /
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to target database: AUGUST (DBID=1248448320)
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP .;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP .;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP .;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\orabac
kup\orcl\%F';
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'E:\orabackup\or
cl\%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\orabackup\or
cl\%F';
new RMAN configuration parameters are successfully stored
RMAN> run
2> {
3> allocate channel c1 device type disk;
4> backup database format 'D:\orabackup\orcl\%u';
5> backup archivelog all format 'D:\orabackup\orcl\%u' delete input;
6> release channel c1;
7> }
released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=141 devtype=DISK
Starting backup at 27-2月 -09
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\AUGUST\SYSTEM01.D
BF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\AUGUST\SYSAUX01.D
BF
input datafile fno=00005 name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\AUGUST\TBS_WORK
input datafile fno=00006 name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\AUGUST\TBS_SYSMGR
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\AUGUST\UNDOTBS01.
DBF
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\AUGUST\USERS01.DB
F
channel c1: starting piece 1 at 27-2月 -09
channel c1: finished piece 1 at 27-2月 -09
piece handle=D:\ORABACKUP\ORCL\03K8DJ5O comment=NONE
channel c1: backup set complete, elapsed time: 00:01:26
Finished backup at 27-2月 -09
Starting backup at 27-2月 -09
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=52 recid=1 stamp=679922959
channel c1: starting piece 1 at 27-2月 -09
channel c1: finished piece 1 at 27-2月 -09
piece handle=D:\ORABACKUP\ORCL\04K8DJ8F comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
channel c1: deleting archive log(s)
archive log filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\AUGUST\ARCHIVE
LOG\2009_02_27\O1_MF_1_52_4TGQJGLS_.ARC recid=1 stamp=679922959
Finished backup at 27-2月 -09
Starting Control File and SPFILE Autobackup at 27-2月 -09
piece handle=D:\ORABACKUP\ORCL\C-1248448320-20090227-00 comment=NONE
Finished Control File and SPFILE Autobackup at 27-2月 -09
RMAN> Delete noprompt obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
no obsolete backups found
还可以做个bat直接进行rman操作,下面是 rman.bat 的内容
rman target / cmdfile=D:\orabackup\orcl\bak.txt log=D:\orabackup\orcl\bak.log
本文转自 august 51CTO博客,原文链接:http://blog.51cto.com/august/133477,如需转载请自行联系原作者