Backup Oracle DB in NOARCHIVELOG mode.In sqlplus console,
1 2 3 4 5 6 7 8 9 10 11 12 13
$ sqlplus / as sysdba (sqlplus /nolog then conn /as sysdba) SQL> archive log list; SQL> show parameter DB_RECOVERY_FILE_DEST; SQL> altersystemset db_recovery_file_dest='/flash_recovery_area' scope=both; SQL> shutdown immediate; SQL> startup mount; // at this time, run RMAN> backup database; // OR change archive log mode SQL> alterdatabase archivelog; SQL> alterdatabaseopen; SQL> archive log list; SQL> altersystem switch logfile; ( ORaltersystem archive logcurrent) SQL> select operation, status, mbytes_processed, start_time, end_time from v$rman_status orderby start_time;
If archivelog mode is enabled
1 2 3 4 5 6 7
RMAN> backup incremental level0database plus archivelog deleteinput; OR RMAN> backup as compressed backupset incremental level0databaseincludecurrent controlfile plus archivelog; OR RMAN> backup as compressed backupset incremental level0databaseincludecurrent controlfile plus archivelog deleteallinput; ADN RMAN> backup incremental level1database plus archivelog deleteinput;
In rman prompt,
1 2 3 4 5 6 7 8 9 10 11 12 13
$ rman RMAN> connect target /; RMAN> list backup; RMAN> list backup summary; RMAN> backup as compressed backupset tag 'weeekly_prd01_tbls_bk_only'tablespace prd01; RMAN> backup as compressed backupset database plus archivelog ;
RMAN> run { # backup directly in noarchive mode shutdown immediate; startup mount; backup database; alterdatabaseopen; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
RMAN> showall; CONFIGURE RETENTION POLICYTO REDUNDANCY 1; CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE DEFAULT DEVICE TYPETO DISK; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMATFOR DEVICE TYPE DISK TO'/tmp/backup/%F'; CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPETO BACKUPSET; CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO1; CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO1; CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT'/tmp/backup/dbkup_%Y%M%D_%U'; CONFIGURE MAXSETSIZE TO UNLIMITED; CONFIGURE ENCRYPTION FORDATABASEOFF; CONFIGURE ENCRYPTION ALGORITHM 'AES128'; CONFIGURE COMPRESSION ALGORITHM 'BASIC'ASOFRELEASE'DEFAULT' OPTIMIZE FORLOADTRUE; CONFIGURE ARCHIVELOG DELETION POLICYTONONE; CONFIGURE SNAPSHOT CONTROLFILE NAMETO'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_CHHDEV2.f';
CONFIGURE RETENTION POLICY TO REDUNDANCY 3; # default 1
# CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS; # default 1
CONFIGURE BACKUP OPTIMIZATION ON; # default OFF
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; # default OFF
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO'${BACKUPDIR}/ora_cf%F'; # default '%F'
CONFIGURE DEVICE TYPE DISK PARALLELISM 3; # default 1
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '${BACKUPDIR}/ora_df%t_s%s_s%p';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO'${BACKUPDIR}/snapcf_${DATABASE}.f';
SHOW ALL;
sql "alter system switch logfile";
CROSSCHECK ARCHIVELOG ALL;
# BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 0 DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG DELETE ALL INPUT;
# BACKUP AS COMPRESSED BACKUPSET DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG DELETE ALL INPUT;
# BACKUP DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG DELETE ALL INPUT;
# backup AS COMPRESSED BACKUPSET database include current controlfile format '${BACKUPDIR}/ora_df%t_s%s_s%p';
# backup AS COMPRESSED BACKUPSET archivelog UNTIL TIME '(SYSDATE - 1)' not backed up 1 times format '${BACKUPDIR}/ora_arc%t_s%s_s%p';
# delete noprompt archivelog until time '(SYSDATE -1)' backed up 1 times to device type disk;
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL ${LEVEL} DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG;
DELETE NOPROMPT COPY OF ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-5';
sql "alter database backup controlfile to trace as ''${BACKUPDIR}/ctrlfile_${DATABASE}_${RUNTIME}''";
allocate channel for maintenance type disk;
delete noprompt obsolete device type disk;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
REPORT OBSOLETE;
DELETE FORCE NOPROMPT OBSOLETE;
DELETE FORCE NOPROMPT expired backup of archivelog all;
DELETE FORCE NOPROMPT expired backup;
LIST BACKUP OF DATABASE;
LIST BACKUP OF ARCHIVELOG ALL;
LIST BACKUP;
release channel;
EXIT
EOF!
exit
Store Oracle DB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
RMAN> SET DBID 70161972; RMAN> RUN { startup force nomount; SET CONTROLFILE AUTOBACKUP FORMATFOR DEVICE TYPE DISK TO'/tmp/backup/%F'; RESTORE CONTROLFILE to'/tmp/controlfile'FROM AUTOBACKUP; RESTORE SPFILE to pfile '/tmp/pfile'FROM AUTOBACKUP; //OR restore controlfile from autobackup; restore spfile from autobackup;
SET ARCHIVELOG DESTINATION TO'/tmp/temp_restore'; RESTORE ARCHIVELOG ALL;