RMAN基本操作程式碼
LINUX> rman
RMAN> connect target /
RMAN> connect catalog rman/rman@rmandb;
RMAN> create catalog tablespace rman_data;
RMAN> register database;
RMAN> list incarnation;
RMAN> report schema;
RMAN> set snapshot controlfile name to '/opt/app/oracle/product/10.2.0/db_1/dbs/snap_terrydb1.ctl';
RMAN> resync catalog;
#rman script
run{
allocate channel d1 type disk;
copy
datafile 1 to '/u04/terry/rmanstudy/rman_bk_copy/system01.dbf.bk',
datafile 2 to '/u04/terry/rmanstudy/rman_bk_copy/undotbs01.dbf.bk',
datafile 3 to '/u04/terry/rmanstudy/rman_bk_copy/sysaux01.dbf.bk',
datafile 4 to '/u04/terry/rmanstudy/rman_bk_copy/users01.dbf.bk',
datafile 5 to '/u04/terry/rmanstudy/rman_bk_copy/wip_tracking_data01a.dbf.bk',
datafile 6 to '/u04/terry/rmanstudy/rman_bk_copy/sfism4_data01a.dbf.bk',
current controlfile to '/u04/terry/rmanstudy/rman_bk_copy/backup.ctl';
}
#generate rman script. with sqlplus
set feedback off pagesize 0 heading off verify off
set linesize 100 trimspool on
define dir='/u04/terry/rmanstudy/rman_bk_copy/sqlscriptrman/'
define fil='/u04/terry/rmanstudy/rman_bk_copy/sqlscriptrman/rmanscript.ora'
define div='/'
spool &fil
prompt run {
prompt allocate channel d1 type disk;;
prompt copy
select 'datafile '||file#||' to '||'''&dir.'||substr(name,(instr(name,'&div',-1)+1))||'.bak.sql'',' from v$datafile;
prompt current controlfile to '&dir.backup.ctl.sql';};
spool off;
#incremental level 0
run {
allocate channel d1 type disk;
backup
incremental level 0
format '/u04/terry/rmanstudy/rman_bk_wholeinc0/db_%d_%s_%p_%t'
tag='WHOLE_INC0'
database;
}
#backup close
shutdown immediate;
startup mount;
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
backup
incremental level 0
format '/u04/terry/rmanstudy/rman_bk_close/db_%d_%s_%p_%t'
tag = 'WHOLE_INC0_CLOSED'
database;
};
sql "alter database backup controlfile to ''/u04/terry/rmanstudy/rman_bk_close/backup.ctl''";
alter database open;
#rman archivelog
run {
allocate channel d1 type disk;
sql "alter system archive log current";
backup
format '/u04/terry/rmanstudy/rman_bk_arch/ar_%d_%s_%p_%t'
tag = 'ARCH_LOG_ALL'
archivelog all;
}
list backupset(backup) of archivelog all ;
#LIST command
RMAN> list backup;
RMAN> list backup of database;
RMAN> list backup of tablespace 'SYSTEM','USERS';
RMAN> list backup of datafile 1,3,7;
RMAN> list backup of datafile
2> '/oradata/db/system01.dbf',
3> '/oradata/db/user01.dbf';
RMAN> list copy;
RMAN> list copy of database;
RMAN> list copy of tablespace 'SYSTEM','USERS';
RMAN> list copy of datafile 1,3,7;
RMAN> list copy of datafile
2> '/oradata/db/system01.dbf',
3> '/oradata/db/user01.dbf';
RMAN> list copy of control file;
RMAN> list backup of archivelog all;
RMAN> list backup of archivelog like '%oradata%';
RMAN> list backup of archivelog from time 'sysdate-14';
RMAN> list backup of archivelog until time 'sysdate-7';
RMAN> list backup of archivelog from time 'sysdate-14' until time 'sysdate-7';
RMAN> list backup of archivelog from scn 100000;
RMAN> list backup of archivelog until scn 110000;
RMAN> list backup of archivelog from scn 100000 until scn 110000;
RMAN> list backup of archivelog from logseq 130;
RMAN> list backup of archivelog until logseq 139;
RMAN> list backup of archivelog from logseq 130 until logseq 139;
RMAN> list backup completed after 'sysdate-14';
RMAN> list backup completed before 'sysdate-7';
RMAN> list backup completed between 'sysdate-14' and 'sysdate-7';
RMAN> list backup tag=WHOLE_INC0;
RMAN> list backup recoverable;
RMAN> list backup device type disk;
RMAN> list copy like '%system%';
RMAN> list backup completed after 'sysdate-14'
2> tag=WHOLE_INC0
3> device type disk
4> recoverable;
RMAN> list backup of tablespace 'RBS'
2> completed after 'LAST_DAY(ADD_MONTHS(SYSDATE,-1))+1'
3> tag=WHOLE_INC0
4> device type disk;
RMAN> list backup completed after 'sysdate-21';
RMAN> list backup of controlfile completed after 'sysdate-21';
RMAN> list backup of archivelog all completed after 'sysdate-21';
RMAN> list backup of of archivelog from logseq 130 until logseq 139
2> completed after 'sysdate-21';
RMAN> list backup recoverable until time 'sysdate-21';
#REPORT command
RMAN> report need backup days 2 database;
RMAN> report need backup incremental 3 database;
RMAN> report unrecoverable;
RMAN> report schema;
RMAN> report schema at time 'sysdate-7';
RMAN> report schema at time "to_date('20080101','yyyymmdd')";
RMAN> report schema at scn 1000;
RMAN> report schema at logseq 131;
#RMAN Skill
#caution
RESETLOGS option only valid after an incomplete database recovery
RMAN> connect target /
RMAN> connect catalog rman/rman@rmandb;
RMAN> create catalog tablespace rman_data;
RMAN> register database;
RMAN> list incarnation;
RMAN> report schema;
RMAN> set snapshot controlfile name to '/opt/app/oracle/product/10.2.0/db_1/dbs/snap_terrydb1.ctl';
RMAN> resync catalog;
#rman script
run{
allocate channel d1 type disk;
copy
datafile 1 to '/u04/terry/rmanstudy/rman_bk_copy/system01.dbf.bk',
datafile 2 to '/u04/terry/rmanstudy/rman_bk_copy/undotbs01.dbf.bk',
datafile 3 to '/u04/terry/rmanstudy/rman_bk_copy/sysaux01.dbf.bk',
datafile 4 to '/u04/terry/rmanstudy/rman_bk_copy/users01.dbf.bk',
datafile 5 to '/u04/terry/rmanstudy/rman_bk_copy/wip_tracking_data01a.dbf.bk',
datafile 6 to '/u04/terry/rmanstudy/rman_bk_copy/sfism4_data01a.dbf.bk',
current controlfile to '/u04/terry/rmanstudy/rman_bk_copy/backup.ctl';
}
#generate rman script. with sqlplus
set feedback off pagesize 0 heading off verify off
set linesize 100 trimspool on
define dir='/u04/terry/rmanstudy/rman_bk_copy/sqlscriptrman/'
define fil='/u04/terry/rmanstudy/rman_bk_copy/sqlscriptrman/rmanscript.ora'
define div='/'
spool &fil
prompt run {
prompt allocate channel d1 type disk;;
prompt copy
select 'datafile '||file#||' to '||'''&dir.'||substr(name,(instr(name,'&div',-1)+1))||'.bak.sql'',' from v$datafile;
prompt current controlfile to '&dir.backup.ctl.sql';};
spool off;
#incremental level 0
run {
allocate channel d1 type disk;
backup
incremental level 0
format '/u04/terry/rmanstudy/rman_bk_wholeinc0/db_%d_%s_%p_%t'
tag='WHOLE_INC0'
database;
}
#backup close
shutdown immediate;
startup mount;
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
backup
incremental level 0
format '/u04/terry/rmanstudy/rman_bk_close/db_%d_%s_%p_%t'
tag = 'WHOLE_INC0_CLOSED'
database;
};
sql "alter database backup controlfile to ''/u04/terry/rmanstudy/rman_bk_close/backup.ctl''";
alter database open;
#rman archivelog
run {
allocate channel d1 type disk;
sql "alter system archive log current";
backup
format '/u04/terry/rmanstudy/rman_bk_arch/ar_%d_%s_%p_%t'
tag = 'ARCH_LOG_ALL'
archivelog all;
}
list backupset(backup) of archivelog all ;
#LIST command
RMAN> list backup;
RMAN> list backup of database;
RMAN> list backup of tablespace 'SYSTEM','USERS';
RMAN> list backup of datafile 1,3,7;
RMAN> list backup of datafile
2> '/oradata/db/system01.dbf',
3> '/oradata/db/user01.dbf';
RMAN> list copy;
RMAN> list copy of database;
RMAN> list copy of tablespace 'SYSTEM','USERS';
RMAN> list copy of datafile 1,3,7;
RMAN> list copy of datafile
2> '/oradata/db/system01.dbf',
3> '/oradata/db/user01.dbf';
RMAN> list copy of control file;
RMAN> list backup of archivelog all;
RMAN> list backup of archivelog like '%oradata%';
RMAN> list backup of archivelog from time 'sysdate-14';
RMAN> list backup of archivelog until time 'sysdate-7';
RMAN> list backup of archivelog from time 'sysdate-14' until time 'sysdate-7';
RMAN> list backup of archivelog from scn 100000;
RMAN> list backup of archivelog until scn 110000;
RMAN> list backup of archivelog from scn 100000 until scn 110000;
RMAN> list backup of archivelog from logseq 130;
RMAN> list backup of archivelog until logseq 139;
RMAN> list backup of archivelog from logseq 130 until logseq 139;
RMAN> list backup completed after 'sysdate-14';
RMAN> list backup completed before 'sysdate-7';
RMAN> list backup completed between 'sysdate-14' and 'sysdate-7';
RMAN> list backup tag=WHOLE_INC0;
RMAN> list backup recoverable;
RMAN> list backup device type disk;
RMAN> list copy like '%system%';
RMAN> list backup completed after 'sysdate-14'
2> tag=WHOLE_INC0
3> device type disk
4> recoverable;
RMAN> list backup of tablespace 'RBS'
2> completed after 'LAST_DAY(ADD_MONTHS(SYSDATE,-1))+1'
3> tag=WHOLE_INC0
4> device type disk;
RMAN> list backup completed after 'sysdate-21';
RMAN> list backup of controlfile completed after 'sysdate-21';
RMAN> list backup of archivelog all completed after 'sysdate-21';
RMAN> list backup of of archivelog from logseq 130 until logseq 139
2> completed after 'sysdate-21';
RMAN> list backup recoverable until time 'sysdate-21';
#REPORT command
RMAN> report need backup days 2 database;
RMAN> report need backup incremental 3 database;
RMAN> report unrecoverable;
RMAN> report schema;
RMAN> report schema at time 'sysdate-7';
RMAN> report schema at time "to_date('20080101','yyyymmdd')";
RMAN> report schema at scn 1000;
RMAN> report schema at logseq 131;
#RMAN Skill
#caution
RESETLOGS option only valid after an incomplete database recovery
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10742223/viewspace-364838/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【基本操作】RMAN 相關
- RMAN基本操作手冊
- sklearn基本操作程式碼練習
- Oracle 11g RMAN備份-基本操作Oracle
- bat指令碼的基本操作BAT指令碼
- rman操作
- rman 基本命令
- Oracle 重置密碼及基本操作Oracle密碼
- Backup And Recovery User's Guide-從RMAN開始-指令碼化RMAN操作GUIIDE指令碼
- Windows下RMAN備份程式碼Windows
- webpack 基本操作Web
- Git基本操作Git
- Laravel 基本操作Laravel
- 基本操作題
- dos 基本操作
- MongoDB基本操作MongoDB
- Redis基本操作Redis
- mongo基本操作Go
- HBase 基本操作
- candance 基本操作
- Hash基本操作
- svn基本操作
- oracle基本操作Oracle
- ElasticSearch基本操作Elasticsearch
- FFMPEG基本操作
- Kafka基本操作Kafka
- SQL基本操作SQL
- Docker 基本操作Docker
- JXL基本操作
- Hive基本操作Hive
- git 基本操作Git
- 基本操作命令
- mysql基本操作MySql
- ElasticSearch - 基本操作Elasticsearch
- Docker基本操作Docker
- Go 操作 Redis 的基本操作GoRedis
- 安川機器人示教程式基本操作機器人
- RMAN的基本知識和指令