oracle10g_rman_語法測試_2

wisdomone1發表於2009-09-16
--ALLOCATE CHANNEL FOR MAINTENANCE
--用於change,delete,crosscheck
限制:
1,僅用於rman提示符下,不能用於run中
2,資料庫必須開啟
3,不能指定通道id
4,不能分配通道到一個共享會話
5,手工分配通道(維護與正常)不能與自動通道分配混用,只能顯式指定
6,通道格式為ora_maint_devicetype_n

RMAN> allocate channel for maintenance device type disk;

using target database control file instead of recovery catalog
allocated channel: ORA_MAINT_DISK_1
channel ORA_MAINT_DISK_1: sid=135 devtype=DISK

RMAN> crosscheck backup of database;
RMAN> crosscheck backup;
RMAN> delete noprompt backup of database;--刪除資料庫的備份
RMAN> delete noprompt backup ;--刪除備份

ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
DELETE NOPROMPT BACKUP OF DATABASE COMPLETED BEFORE 'SYSDATE-7';---刪除七號前的資料庫備份

--利用configure配置永久型配置,只要不是顯式指定,就會使用configure的配置
RMAN> configure channel device type disk format='/oracle/auto/backup_%U';

RMAN> run
2> {
3> backup database;
4> }

connect --rac中
send   --發實與介質特有的
maxopenfiles
maxpiecesize
rate


不完全恢復後的resetlogs
run
{
allocate channel c1 device type disk;
set until scn 1024;
restore database;
recover database;
alter database open resetlogs;
}


--
configure controlfile autobackup on;--開戶控制檔案自動備份,只要你backup database後


RMAN> backup device type disk database;

fileperset  ---每個備份集中的檔案數

force ---配備了它,就忽略configure backup optimization on;

RMAN> backup incremental level=0 database;--它類同於全庫備份,但它是其它增量備份的基礎
RMAN> backup incremental level=1 database; --如果沒有0 level備份,rman會自動進行0級備份
--rman不支援控制檔案,歸檔日誌檔案和備份集
RMAN> backup incremental level=1  datafile 1; ---物件可為datafile,datafilecopy,tablepace,database
--INCREMENTAL FROM SCN=  ---用於在standby database應用主庫的歸檔日誌,呵呵
maxsetsize ---指定備份集的大小

backup nochecksum datafile 3;  ---nochecksum選項跟在backup後,db_block_checksum

RMAN> backup database skip offline; --offline也可為readonly 或inaccessable
RMAN> backup validate database; --validate 驗證是否可以備份,不能對備份集進行validate

--RECOVERY AREA | DB_RECOVERY_FILE_DEST
backup recovery area;--僅於sbt,RECOVERY FILES相同
DELETE [ALL] INPUT  --all僅用於archive log
RMAN>  backup database include current controlfile;---後可加上for standby
RMAN> backup as copy datafile 1; ---一對一的檔案copy,只用於disk channel的備份

RMAN> backup as backupset database;--對備份集進行備份,AS BACKUPSET 用於到 sbt
RMAN> backup copy of datafile 1; ---對資料檔案1的copy再作一個備份,datafile可換為tablespace,database
RMAN> backup as copy datafile 1 format='/oracle/newly_%U';
rman>backup datafilecopy 映象檔案備份檔案|all|like ''|from tag







# Run once a week to back up database to disk as level 0:
BACKUP INCREMENTAL LEVEL 0 DATABASE;--0級備份

# Run every day to back up blocks that have changed since most recent level 0 or 1:
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;--累積備份
BACKUP INCREMENTAL LEVEL 1 DIFFERENTIAL TABLESPACE users;--差異備份


RMAN> backup incremental level 1 cumulative skip readonly database; ---增量備份資料庫,加上skip選項


----把相關的檔案搞成一個備份集
RMAN> run
2> {
3> backup as backupset
4> (tablespace zxy)
5> (datafile 2);
6> }

--對相關檔案進行映象備份
RMAN> run
2> {
3> backup as copy (tablespace zxy) ( datafile 4);}


--查到資料檔案的映象複製,儲存到/copies目錄
BACKUP AS COPY
   FROM TAG 'LATESTCOPY'
  COPY OF DATAFILE 4, 6, 14
  FORMAT '/copies/Datafile%f_Database%d';


MAN> backup archivelog all format '/oracle/arch_%U';


RMAN> backup archivelog like '/oracle/flash_recovery_area%' delete all input;--利用like備份歸檔日誌,然後刪除歸檔日誌

BACKUP DEVICE TYPE disk  BACKUPSET COMPLETED BEFORE 'SYSDATE-14'  --只備份14天前的備份集
  DELETE INPUT;


RMAN> configure default device type to disk;---配置預設備份裝置

RMAN> backup copies 2 tablespace zxy format '/oracle/bak1_%U','/oracle/bak2_%U';---備份(datafile,tablespace,database)時同時進行兩分備份


RUN
{
  ALLOCATE CHANNEL ch1 DEVICE TYPE sbt PARMS="ENV=(NSR_SERVER=tape_server_1)"; --指定不同的通道,
  ALLOCATE CHANNEL ch2 DEVICE TYPE DISK;
  ALLOCATE CHANNEL ch3 DEVICE TYPE sbt PARMS="ENV=(NSR_SERVER=tape_server_2)";
  BACKUP
    (DATAFILE 1,2,3,4        # channel ch1 backs up datafiles to tape drive #1  ---把不同的備份指定到不同以上定義的通道
    CHANNEL ch1)
    (CONTROLFILECOPY '/oracle/copy/cf.f'
    CHANNEL ch2)             # channel ch2 backs up control file copy to disk
    (ARCHIVELOG FROM TIME 'SYSDATE-14'
    CHANNEL ch3);            # channel ch3 backs up archived redo logs to tape drive #2
}


---在主庫生成增量備份,用於應用在備庫上
backup incremental from scn 788 database format '/oracle/tmp_U';


---備份資料檔案3,可以容忍2個塊損壞
run
{
set maxcorrupt for datafile 3 to 2;
backup check logical
datafile 3;
}

--對資料庫的映象複製(標記為zxy),作一個備份到預設位置,生成標記為duptest,然後實行邏輯檢查
backup as copy copy of database from tag 'zxy' check logical tag 'duptest';


SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
BACKUP DATABASE
  KEEP UNTIL TIME 'SYSDATE+365'  --利用keep和nologs使生成的備份集從保持日期中免除(物殊化),或者永遠免除keep forever nologs
  NOLOGS;
ALTER DATABASE OPEN;



--備份需要備份的檔案
backup device type disk database not backed up since time 'sysdate -31';--備份一個月來沒有備份
BACKUP DEVICE TYPE sbt ARCHIVELOG ALL NOT BACKED UP 2 TIMES;---只備份沒有備份兩次的歸檔日誌

RMAN> backup datafilecopy all; --備份所有資料檔案映象複製


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-614736/,如需轉載,請註明出處,否則將追究法律責任。

相關文章