Possiamo usare RMAN per eseguire il backup di tutte le parti del database Oracle. I comandi di backup RMAN possono essere utilizzati per eseguire il backup di file di database Oracle, copie di file di database, registri archiviati o set di backup.
Ecco la sintassi generale per il comando di backup RMAN
Syntax: BACKUP FULL Options BACKUP FULL AS (COPY | BACKUPSET) Options BACKUP INCREMENTAL LEVEL [=] integer Options BACKUP INCREMENTAL LEVEL [=] integer AS (COPY | BACKUPSET) Options BACKUP AS (COPY | BACKUPSET) Options BACKUP AS (COPY | BACKUPSET) (FULL | INCREMENTAL LEVEL [=] integer) Options Options: [backupOperand [backupOperand]...] backupSpec [backupSpec]... [PLUS ARCHIVELOG [backupSpecOperand [backupSpecOperand]...]]; backupOperand::= { FORMAT [=] 'format_string' [, 'format_string']... | CHANNEL ['] channel_id ['] | CUMULATIVE | MAXSETSIZE [=] integer [ K | M | G ] | TAG [=] ['] tag_name ['] | keepOption | SKIP { OFFLINE | READONLY | INACCESSIBLE } | VALIDATE | NOT BACKED UP [SINCE TIME [=] 'date_string'] | COPIES [=] integer | DEVICE TYPE deviceSpecifier . . . } backupSpec::= [(] { BACKUPSET { {ALL | completedTimeSpec } | primary_key) [, primary_key]... } | COPY OF { DATABASE | TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]... | DATAFILE datafileSpec [, datafileSpec]... } | DATAFILE datafileSpec [, datafileSpec]... | DATAFILECOPY 'filename' [, 'filename']... | DATAFILECOPY FROM TAG [=] ['] tag_name ['] [, ['] tag_name [']]... | DATAFILECOPY { ALL | LIKE 'string_pattern' } | TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]... | DATABASE | archivelogRecordSpecifier | CURRENT CONTROLFILE [FOR STANDBY] | CONTROLFILECOPY 'filename' | SPFILE } [backupSpecOperand [backupSpecOperand]...] backupSpecOperand::= { FORMAT [=] 'format_string' [, 'format_string']... | CHANNEL ['] channel_id ['] | CUMULATIVE | MAXSETSIZE [=] integer [ K | M | G ] | TAG [=] ['] tag_name ['] | keepOption | SKIP { OFFLINE | READONLY | INACCESSIBLE } | NOT BACKED UP [ SINCE TIME [=] 'date_string' | integer TIMES ] | DELETE [ALL] INPUT . . . } .
Dovresti configurare i dispositivi e i canali predefiniti prima di eseguire RMAN Backup.
For disk RUN { ALLOCATE CHANNEL disk01 TYPE disk ; ALLOCATE CHANNEL disk02 TYPE disk ; ALLOCATE CHANNEL disk03 TYPE disk ; BACKUP DATABASE FORMAT '${ORACLE_SID}-%U'; } For tape RUN { ALLOCATE CHANNEL tape01 TYPE 'SBT_TAPE' ; ALLOCATE CHANNEL tape02 TYPE 'SBT_TAPE' ; ALLOCATE CHANNEL tape03 TYPE 'SBT_TAPE' ; BACKUP DATABASE FORMAT '${ORACLE_SID}-%U'; } or RUN { ALLOCATE CHANNEL tape01 TYPE sbt ; ALLOCATE CHANNEL tape02 TYPE sbt ; ALLOCATE CHANNEL tape03 TYPE sbt ; BACKUP DATABASE FORMAT '${ORACLE_SID}-%U'; }
RMAN inserisce il backup nell'area di ripristino flash nel caso in cui il tipo di dispositivo sia disco e non sia stato specificato alcun formato
Ecco un elenco completo dei comandi di backup RMAN
Comando del database RMAN BACKUP
RMAN> BACKUP DATABASE; RMAN> BACKUP DATABASE TAG=’test backup’; RMAN> BACKUP DATABASE COMMENT=’full backup’; RMAN> BACKUP TAG 'weekly_full_db_bkup' DATABASE MAXSETSIZE 10M; RMAN> BACKUP MAXSETSIZE 500M DATABASE PLUS ARCHIVELOG; RMAN> BACKUP DURATION 00:60 DATABASE; RMAN> BACKUP DURATION 00:30 MINIMIZE TIME DATABASE; RMAN> BACKUP DURATION 00:45 MINIMIZE LOAD DATABASE;
Puoi eseguire il backup del database e dell'archivio contemporaneamente utilizzando il comando seguente
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
Esegue i passaggi seguenti per avere un backup coerente
a.Esegue il comando ALTER SYSTEM ARCHIVE LOG CURRENT.
b.Esegue BACKUP ARCHIVELOG ALL. Tieni presente che se l'ottimizzazione del backup è abilitata, RMAN ignora i registri di cui è già stato eseguito il backup sul dispositivo specificato.
c.Esegue il backup del resto dei file specificati nel comando BACKUP.
d. Esegue il comando ALTER SYSTEM ARCHIVE LOG CURRENT.
d. Esegue il backup di tutti i log archiviati rimanenti generati durante il backup.
Ciò garantisce che i backup dei file di dati eseguiti durante il comando siano ripristinabili in uno stato coerente.
RMAN> BACKUP DATABASE KEEP FOREVER; RMAN> BACKUP DATABASE KEEP UNTIL TIME=’SYSDATE+30’; RMAN> BACKUP DATABASE UNTIL 'SYSDATE+365' NOLOGS; RMAN> BACKUP DATABASE NOEXCLUDE; RMAN> BACKUP DATABASE NOEXCLUDE KEEP FOREVER TAG=’abc’; RMAN> BACKUP DATABASE SKIP READONLY; RMAN> BACKUP DATABASE SKIP OFFLINE; RMAN> BACKUP DATABASE SKIP INACCESSIBLE; RMAN> BACKUP DATABASE SKIP READONLY SKIP OFFLINE SKIP INACCESSIBLE; RMAN> BACKUP DATABASE FORCE; -- backup read only database also RMAN> BACKUP DATABASE NOT BACKED UP; RMAN> BACKUP DATABASE NOT BACKED UP SINCE TIME=’SYSDATE–3’; RMAN> BACKUP NOT BACKED UP SINCE TIME 'SYSDATE-10' MAXSETSIZE 500M DATABASE PLUS ARCHIVELOG;
RMAN> BACKUP DATABASE COPIE=2;
Ecco alcuni formati che puoi utilizzare per il backup
RMAN> BACKUP DATABASE FORMAT '/disk1/backups/db_%U.bck' RUN { ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/disk1/%d_backups/%U'; ALLOCATE CHANNEL disk2 DEVICE TYPE DISK FORMAT '/disk2/%d_backups/%U'; ALLOCATE CHANNEL disk3 DEVICE TYPE DISK FORMAT '/disk3/%d_backups/%U'; BACKUP AS COPY DATABASE; } RMAN> BACKUP DEVICE TYPE DISK DATABASE; RMAN> BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG; RMAN> BACKUP DEVICE TYPE sbt DATAFILECOPY FROM TAG 'latest' FORMAT 'df%f_%d'; RMAN> BACKUP DEVICE TYPE sbt ARCHIVELOG LIKE '/disk%arc%' DELETE ALL INPUT; RMAN> BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-14'DELETE INPUT; RMAN> BACKUP CHECK LOGICAL DATABASE; RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE; RMAN> BACKUP VALIDATE DATABASE; RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
Comando RMAN Backup Tablespace
RMAN> BACKUP TABLESPACE test; RMAN> BACKUP TABLESPACE system, users, tools; RMAN> BACKUP TABLESPACE 4; RMAN> BACKUP TABLESPACE USERS PLUS ARCHIVELOG; RMAN> BACKUP TABLESPACE USERS INCLUDE CURRENT CONTROLFILE; RMAN> BACKUP TABLESPACE USERS INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG; RMAN> BACKUP TABLESPACE USERS SECTION SIZE 100M; RMAN> BACKUP SECTION SIZE 250M TABLESPACE USERS;
Comando RMAN backup datafile
RMAN> BACKUP DATAFILE 9; RMAN> BACKUP DATAFILE ‘/u01/data/...’; RMAN> BACKUP DATAFILE 1 PLUS ARCHIVELOG; RMAN> BACKUP KEEP FOREVER FORMAT '?/dbs/%U_longterm.cpy' TAG longterm_bck DATAFILE 1 DATAFILE 2; RMAN> BACKUP SECTION SIZE 500M DATAFILE 6;
Comando RMAN backup archivio log
RMAN> BACKUP ARCHIVELOG ALL; RMAN> BACKUP ARCHIVELOG ALL DELETE INPUT; RMAN> BACKUP ARCHIVELOG LIKE '/arch%' DELETE ALL INPUT; RMAN> BACKUP ARCHIVELOG FROM TIME ‘SYSDATE–3’; RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 100; RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 999 DELETE INPUT; RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 123 DELETE ALL INPUT; RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 21531 UNTIL SEQUENCE 21590 FORMAT '/tmp/archive_backup.bkp'; RMAN> BACKUP ARCHIVELOG ALL FROM SEQUENCE 1200 DELETE ALL INPUT; RMAN> BACKUP ARCHIVELOG NOT BACKED UP 2 TIMES; RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN 'SYSDATE-28' AND 'SYSDATE-7'; RMAN> BACKUP FORMAT='AL_%d/%t/%s/%p' ARCHIVELOG LIKE '%arc_dest%';
Comando del file di controllo del backup RMAN
RMAN> BACKUP CURRENT CONTROLFILE TO '/backup/cntrlfile.copy'; RMAN> BACKUP CONTROLFILE COPY ‘/u10/backup/control.bkp’;
Comando spfile di backup RMAN
RMAN> BACKUP SPFILE; RMAN> BACKUP DEVICE TYPE sbt SPFILE ARCHIVELOG ALL; RMAN> BACKUP DEVICE TYPE sbt DATAFILECOPY ALL NODUPLICATES; RMAN> BACKUP RECOVERY FILES;
Comando di backup del database collegabile RMAN
RMAN>BACKUP PLUGGABLE DATABASE PDB1, PDB2;
Set di BACKUP
RMAN> BACKUP BACKUPSET ALL; RMAN> BACKUP BACKUPSET ALL FORMAT = ‘/u01/.../backup_%u.bak’; RMAN> BACKUP BACKUPSET COMPLETED BEFORE ‘SYSDATE-3’ DELETE INPUT; RMAN> BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-14' DELETE INPUT; RMAN> BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL; RMAN> BACKUP AS COMPRESSED BACKUPSET; RMAN> BACKUP AS COMPRESSED BACKUPSET DEVICE TYPE DISK COPIES 2 DATABASE FORMAT '/disk1/db_%U', '/disk2/db_%U'; RMAN> BACKUP AS COMPRESSED BACKUPSET INCREMENTAL FROM SCN 4111140000000 DATABASE TAG 'RMAN_RECOVERY'; RMAN> BACKUP AS BACKUPSET DATAFILE '$ORACLE_HOME/oradata/users01.dbf','$ORACLE_HOME/oradata/tools01.dbf'; RMAN> BACKUP AS BACKUPSET DATAFILECOPY ALL; RMAN> BACKUP AS BACKUPSET DATAFILECOPY ALL NODUPLICATES;
Backup RMAN come comando di copia o di copia IMAGE
RMAN> BACKUP AS COPY DATABASE; RMAN> BACKUP AS COPY COPY OF DATABASE FROM TAG 'test' CHECK LOGICAL TAG 'duptest'; RMAN> BACKUP AS COPY TABLESPACE 8; RMAN> BACKUP AS COPY TABLESPACE test; RMAN> BACKUP AS COPY TABLESPACE system, tools, users, undotbs; RMAN> BACKUP AS COPY DATAFILE 1; RMAN> BACKUP AS COPY DATAFILE 2 FORMAT '/disk2/df2.cpy' TAG my_tag; RMAN> BACKUP AS COPY CURRENT CONTROLFILE; RMAN> BACKUP AS COPY CURRENT CONTROLFILE FORMAT ‘/....’; RMAN> BACKUP AS COPY ARCHIVELOG ALL; RMAN> BACKUP AS COPY KEEP FOREVER NOLOGS CURRENT CONTROLFILE FORMAT '?/oradata/cf_longterm.cpy', DATAFILE 1 FORMAT '?/oradata/df1_longterm.cpy', DATAFILE 2 FORMAT '?/oradata/df2_longterm.cpy'; RMAN> BACKUP AS COPY DATAFILECOPY 'bar' FORMAT 'foobar'; RMAN> BACKUP AS COPY DATAFILECOPY '/disk2/df2.cpy' FORMAT '/disk1/df2.cpy'; RMAN> BACKUP AS COPY REUSE TARGETFILE '/u01/oracle/11.2.0.2/dbs/orapwcrd' AUXILIARY FORMAT '/u01/oracle/11.2.0.2/dbs/orapwcrd'; RMAN> BACKUP AS COPY CURRENT CONTROLFILE FOR STANDBY AUXILIARY format '+DATA/crd/data1/control01.ctl';
Backup incrementali RMAN
RMAN> BACKUP INCREMENTAL LEVEL=0 DATABASE; RMAN> BACKUP INCREMENTAL LEVEL=1 DATABASE; RMAN> BACKUP INCREMENTAL LEVEL=0 DATABASE PLUS ARCHIVELOG; RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SKIP INACCESSIBLE DATABASE; RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr' DATABASE; RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'oltp' DATABASE; RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 351986 DATABASE FORMAT '/tmp/incr_standby_%U'; RMAN> BACKUP INCREMENTAL FROM SCN 629184 DATAFILE 5 FORMAT '/tmp/ForStandby_%U' TAG 'FORSTANDBY'; RMAN> BACKUP INCREMENTAL LEVEL = --- tablespace/datafile
Articoli correlati
Comandi di backup dell'elenco RMAN:i comandi di backup dell'elenco RMAN vengono utilizzati per elencare il backup eseguito utilizzando RMAN, data e ora e molti altri dettagli sono inclusi
Connessione RMAN decodificata
Cheatsheet dei comandi RMAN di Oracle:Scarica il cheatsheet di RMAN per il vari comandi su backup e ripristino
recuperare database utilizzando RMAN:come ripristinare database utilizzando RMAN, comando di ripristino e ripristino, parallelismo
Come eseguire il debug della sessione Oracle RMAN:come eseguire il debug della sessione RMAN per errore e blocco
RMAN-06059 :Scopri come risolvere l'RMAN-06059:registro archiviato previsto non trovato, la perdita del registro archiviato compromette la recuperabilità
RMAN-20004 :RMAN-20004 si verifica quando un database è stato clonato ed è stata stabilita una connessione dal clone al catalogo utilizzando rman senza modificare il DBID del clone,
ORA-00245:il file di controllo snapshot è una nuova funzionalità di RMAN per la risincronizzazione. Cambiamenti importanti con esso da 11gR2 e come risolvere l'errore ORA-00245