使用RMAN备份
-- 直接使用命令行
[oracle@rhel5 admin]$ rman target sys/oracle
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Sep 5 03:37:34 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: WAILON (DBID=2747751647)
-- 查看数据库的表空间及文件
RMAN> report schema;
Report of database schema for database with db_unique_name WAILON
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 730 SYSTEM *** /u01/app/oracle/oradata/system01.dbf
2 650 SYSAUX *** /u01/app/oracle/oradata/sysaux01.dbf
3 1075 UNDOTBS1 *** /u01/app/oracle/oradata/undotbs01.dbf
4 78 USERS *** /u01/app/oracle/oradata/users01.dbf
5 916 TBS_LRJ *** /u01/app/oracle/oradata/lrj.dbf
6 5 TRANS_TBS *** /home/oracle/trans_tbs.dbf
7 100 WAILON *** /u01/app/oracle/oradata/wailon/WAILON/datafile/o1_mf_wailon_94g6p2k8_.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 100 TEMP01 500 /u01/app/oracle/oradata/wailon/temp01.dbf
-- 查看1天未备份的文件
RMAN> report need backup days 1;
Report of files whose recovery needs more than 1 days of archived logs
File Days Name
---- ----- -----------------------------------------------------
-- COPY备份当前控制文件
RMAN> copy current controlfile to '/home/oracle/wailon-controlfile.ctl';
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/home/oracle/wailon-controlfile.ctl tag=TAG20130929T085014 RECID=29 STAMP=827398215
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
-- COPY备份6号数据文件
RMAN> copy datafile 6 to '/home/oracle/rmanbk/trans_tbs.dbf';
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/home/oracle/trans_tbs.dbf
output file name=/home/oracle/rmanbk/trans_tbs.dbf tag=TAG20130929T085255 RECID=30 STAMP=827398375
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
RMAN> backup spfile;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_nnsnf_TAG20130929T085412_94gyknkk_.bkp tag=TAG20130929T085412 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
--控制文件备份
RMAN> backup current controlfile;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_ncnnf_TAG20130929T085429_94gyl6hr_.bkp tag=TAG20130929T085429 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
-- 归档日志文件备份
RMAN> backup archivelog sequence 232;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=232 RECID=65 STAMP=827386069
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_annnn_TAG20130929T085642_94gypbvl_.bkp tag=TAG20130929T085642 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
RMAN> backup archivelog sequence between 232 and 235;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=232 RECID=65 STAMP=827386069
input archived log thread=1 sequence=233 RECID=66 STAMP=827386766
input archived log thread=1 sequence=234 RECID=67 STAMP=827386766
input archived log thread=1 sequence=235 RECID=68 STAMP=827386766
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_annnn_TAG20130929T085729_94gyqskl_.bkp tag=TAG20130929T085729 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
-- 备份所有的归档日志文件,然后删除
RMAN> backup archivelog all delete input;
Starting backup at 29-SEP-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=232 RECID=65 STAMP=827386069
input archived log thread=1 sequence=233 RECID=66 STAMP=827386766
input archived log thread=1 sequence=234 RECID=67 STAMP=827386766
input archived log thread=1 sequence=235 RECID=68 STAMP=827386766
input archived log thread=1 sequence=236 RECID=69 STAMP=827398661
input archived log thread=1 sequence=237 RECID=70 STAMP=827398694
input archived log thread=1 sequence=238 RECID=71 STAMP=827398873
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_annnn_TAG20130929T090114_94gyytvd_.bkp tag=TAG20130929T090114 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/1_232_817379463.dbf RECID=65 STAMP=827386069
archived log file name=/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_233_94gm4g6q_.arc RECID=66 STAMP=827386766
archived log file name=/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_234_94gm4gc0_.arc RECID=67 STAMP=827386766
archived log file name=/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_235_94gm4gdr_.arc RECID=68 STAMP=827386766
archived log file name=/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_236_94gyr4x0_.arc RECID=69 STAMP=827398661
archived log file name=/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_237_94gys6kc_.arc RECID=70 STAMP=827398694
archived log file name=/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_238_94gyystz_.arc RECID=71 STAMP=827398873
Finished backup at 29-SEP-13
-- 全库备份
RMAN> backup database;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/lrj.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/sysaux01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/wailon/WAILON/datafile/o1_mf_wailon_94g6p2k8_.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/users01.dbf
input datafile file number=00006 name=/home/oracle/trans_tbs.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_nnndf_TAG20130929T080528_94gvp9fh_.bkp tag=TAG20130929T080528 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 29-SEP-13
Starting Control File and SPFILE Autobackup at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/autobackup/2013_09_29/o1_mf_s_827395594_94gvrc2r_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 29-SEP-13
-- 表空间备份
RMAN> backup tablespace TRANS_TBS;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/trans_tbs.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_nnndf_TAG20130929T081008_94gvz10b_.bkp tag=TAG20130929T081008 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
-- 数据文件备份
RMAN> backup datafile '/home/oracle/trans_tbs.dbf';
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/trans_tbs.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_nnndf_TAG20130929T081030_94gvzpz4_.bkp tag=TAG20130929T081030 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
-- 备份表空间,类型为IMAGE COPY
RMAN> backup as copy tablespace TRANS_TBS;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/home/oracle/trans_tbs.dbf
output file name=/u01/app/oracle/flash_recovery_area/WAILON/datafile/o1_mf_trans_tb_94gw1bsp_.dbf tag=TAG20130929T081122 RECID=28 STAMP=827395883
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
-- 压缩备份集
RMAN> backup as compressed backupset datafile 6;
Starting backup at 29-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/trans_tbs.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_nnndf_TAG20130929T091126_94gzkyyk_.bkp tag=TAG20130929T091126 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-13
RMAN> exit
Recovery Manager complete.
--使用RMAN调用脚本备份
[oracle@rhel5 ~]$ vi backup.rcv
run{
backup as copy database;
delete obsolete;
}
"backup.rcv" [New] 3L, 32C written
[oracle@rhel5 ~]$ rman target sys/oracle@wailon cmdfile=backup.rcv log=backup.log
RMAN> 2> 3> 4>
-- 查看脚本的备份结果
[oracle@rhel5 ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Sep 5 03:42:33 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: WAILON (DBID=2747751647)
RMAN> list copy;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
26 1 A 05-SEP-13 611470 05-SEP-13 /u01/app/flash_recovery_area/WAILON/datafile/o1_mf_system_92h345rj_.dbf
28 2 A 05-SEP-13 611495 05-SEP-13 /u01/app/flash_recovery_area/WAILON/datafile/o1_mf_undotbs0_92h35rbf_.dbf
27 3 A 05-SEP-13 611483 05-SEP-13 /u01/app/flash_recovery_area/WAILON/datafile/o1_mf_sysaux_92h34xk5_.dbf
29 4 A 05-SEP-13 611501 05-SEP-13 /u01/app/flash_recovery_area/WAILON/datafile/o1_mf_user01_92h35xpt_.dbf
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
1 1 24 A 13-JUN-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_06_13/o1_mf_1_24_8vl39g8x_.arc
2 1 25 A 13-JUN-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_07_29/o1_mf_1_25_8zdsm54w_.arc
3 1 26 A 29-JUL-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_09_04/o1_mf_1_26_92fpv7qd_.arc
4 1 27 A 04-SEP-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_09_04/o1_mf_1_27_92g32mh3_.arc
5 1 28 A 04-SEP-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_09_04/o1_mf_1_28_92gmd5qq_.arc
6 1 29 A 04-SEP-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_09_05/o1_mf_1_29_92gwghv0_.arc
7 1 30 A 05-SEP-13 /u01/app/flash_recovery_area/WAILON/archivelog/2013_09_05/o1_mf_1_30_92gyqqy1_.arc
-- 在RMAN创建备份脚本,需要使用CATALOG管理
RMAN> create script full_backup
2> {
3> backup database plus archivelog;
4> delete obsolete;
5> }
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of create script command at 09/05/2013 03:43:59
RMAN-06002: command not allowed when not connected to a recovery catalog
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/429786/viewspace-776764/ ,如需转载,请注明出处,否则将追究法律责任。