Automated Backup with RMAN
手動:
rman target / nocatalog RMAN> configure controlfile autobackup format for device type disk to '/mnt/nfs_fs13/from_ora10g/win/db_full/%F'; RMAN> configure controlfile autobackup on; RMAN> configure channel device type disk format = '/mnt/nfs_fs13/from_ora10g/win/db_full/%U'; RMAN> crosscheck archivelog all; RMAN> delete noprompt force expired archivelog all; RMAN> backup database plus archivelog delete input; RMAN> configure controlfile autobackup off;
TIPs:
- 備份檔如要切割成多個檔案,可以加上這參數
configure maxsetsize to 30G;
註:最小的 size 必須大於一個 datafile 的大小。- 清除設定參數的指令
configure maxsetsize clear;
run { crosscheck archivelog all; delete noprompt force expired archivelog all; backup archivelog all format '/path/to/backup/ora-sid/arc_%T_%s_%t_p%p' delete input; }
run { BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/path/to/backup/ora-sid/control01.ctl'; }
SQL> connect / as sysdba Connected. SQL> show parameters spfile; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string /opt/oracle/product/10.2.0.db_ 1/dbs/spfiletopprod.ora
cp /opt/oracle/product/10.2.0.db_1/dbs/spfiletopprod.ora /mnt/tpeitpap01_nfs/from_tpemisep12/spfiletopprod.ora.`date +"%F"`
RMAN> configure exclude for tablespace 'TBS1'; RMAN> configure exclude for tablespace 'TBS2';
其他參數
To list the excludes tablespace RMAN> show exclude; You can override this exclusion feature by explicitly issuing keyword NOEXCLUDE in order to take whole database backup. RMAN> backup database noexclude; Clear the Excluded SAMTBS1 tablespace RMAN> configure exclude for tablespace 'TBS1' clear;
在 RMAN scripts 內加上這幾行
run { allocate channel d1 type DISK; allocate channel d2 type DISK; backup as backupset archivelog all format ..... ... release channel d1; release channel d2; }
Format | Description |
%a | Current database activation id |
%A | Zero-filled activation ID |
%c | The copy number of the backup piece within a set of duplexed backup pieces.bMaximum value is 256 |
%d | Database name |
%D | Current day of the month from the Gregorian calendar in format DD |
%e | Archived log sequence number |
%f | Absolute file number |
%F | Combines the DBID, day, month, year, and sequence into a unique and repeatable generated name |
%h | Archived redo log thread number |
%I | DBID |
%M | Month in the Gregorian calendar in the format MM |
%n | Database name, padded on the right with x characters to a total length of eight characters |
%N | Tablespace name. Only valid when backing up datafiles as image copies. |
%p | Piece number within the backup set. This value starts at 1 for each backup set and is incremented by 1 for each backup piece created. If a PROXY is specified, the %p variable must be included in the FORMAT string either explicitly or implicitly within %U. |
%r | Resetlogs ID |
%s | Backup set number. This number is a counter in the control file that is incremented for each backup set. The counter value starts at 1 and is unique for the lifetime of the control file. If you restore a backup control file, then duplicate values can result. CREATE CONTROLFILE initializes the counter at 1. |
%S | Zero-filled sequence number |
%t | Backup set time stamp, a 4-byte value derived as the number of seconds elapsed since a fixed reference time. The combination of %s and %t can be used to form a unique name for the backup set. |
%T | Year, month, and day in the Gregorian calendar in the format: YYYYMMDD |
%u | An 8-character name constituted by compressed representations of the backup set or image copy number and the time the backup set or image copy was created |
%U | A system-generated unique filename (default). %U is different for image copies and backup pieces. For a backup piece, %U is a shorthand for %u_%p_%c and guarantees uniqueness in generated backup filenames. For an image copy of a datafile, %U means the following: data-D-%d_id-%I_TS-%N_FNO-%f_%u For an image copy of an archived redo log, %U means the following: arch-D_%d-id-%I_S-%e_T-%h_A-%a_%u For an image copy of a control file, %U means the following: cf-D_%d-id-%I_%u |
%Y | Year in this format: YYYY |
%% | Percent (%) character. For example, %%Y translates to the string %Y |
full backup
configure retention policy to redundancy ${RMAN_KEEP}; run { backup as compressed backupset database format '${rman_dest}/%d_DB_%s_%T_%U.rman' filesperset 5; sql 'alter system archive log current'; backup as backupset archivelog all format '${rman_dest}/%d_ARC_%s_%T_%U.rman' skip inaccessible filesperset 20 delete all input; backup current controlfile format '${rman_dest}/%d_CTL_%s_%T_%U.rman'; backup spfile format '${rman_dest}/%d_SPFILE_%s_%T_%U.rman'; crosscheck archivelog all; delete noprompt force expired archivelog all; delete force noprompt obsolete; }
archive backup
run { crosscheck archivelog all; delete noprompt force expired archivelog all; backup as backupset archivelog all format '${rman_dest}/%d_ARC_%s_%T_%U.rman' skip inaccessible filesperset 20 delete all input; backup current controlfile format '${rman_dest}/%d_CTL_%s_%T_%U.rman'; }
Images 0 | ||
---|---|---|
No images to display in the gallery. |