--------------------------------------------------------------------------------------------
-- Consistent Whole backup:
--------------------------------------------------------------------------------------------
Note It is assumed we have configured Rman to backup to a specified location already
Database Must be closed
RMAN> shutdown immediate;
database closed
database dismounted
Oracle instance shut down
RMAN> startup mount;
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 313860096 bytes
Fixed Size 1299624 bytes
Variable Size 255855448 bytes
Database Buffers 50331648 bytes
Redo Buffers 6373376 bytes
RMAN> backup database;
...
RMAN> sql'ALTER SYSTEM ACHIVE LOG CURRENT';
-------------------------------------------------------------------------------------------
-- InConsistent Whole backup:
-------------------------------------------------------------------------------------------
--Database must be open
RMAN> alter database open;
database opened
-- Backups the database plus control files and archive logs.
RMAN> backup database plus archivelog;
-- Plus Archivelog does the following for us:
-- Runs alter system archivelog current
--Runs Backup archivelog all
--(Then the normal backup command fires)
--Runs alter system archivelog current
--Backups any logs created during the backup.
-------------------------------------------------------------------------------------------
-- Backup a Tablespace:
-------------------------------------------------------------------------------------------
RMAN> backup tablespace USERS plus archivelog;
-- We can use the "report schema" rman command to get a list of tablespaces or datafiles from the current target database.
-------------------------------------------------------------------------------------------
-- Backup a Datafile:
-------------------------------------------------------------------------------------------
--using the report schema command again to get the name of the datafile
RMAN> backup datafile '+DATA/prod/datafile/example.269.653867209';
--or i can use the file number..
RMAN> backup datafile 5;
--------------------------------------------------------------------------------------------
-- Backup the Control file or Spfile:
--------------------------------------------------------------------------------------------
RMAN> backup current controlfile;
RMAN> backup spfile;
But as we want to backup the controlfile/spfile with every backup its best to:
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;
-------------------------------------------------------------------------------------------
-- Backup the Archive Logs:
-------------------------------------------------------------------------------------------
RMAN> backup archivelog all;
--or we can be more specific using
"all, from, high, like, logseq, low, scn, sequence, time, until"
eg:
RMAN> backup archivelog FROM SEQUENCE 9;
or
RMAN> backup archivelog from time 'sysdate -1';
or
RMAN> backup archivelog from time 'sysdate -1' until time 'sysdate';
--------------------------------------------------------------------------------------------
-- Backup commpression :
--------------------------------------------------------------------------------------------
RMAN> backup AS COMPRESSED BACKUPSET database plus archivelog;
--------------------------------------------------------------------------------------------
-- Validate files can be Backed Up :
--------------------------------------------------------------------------------------------
--Use the validate command to check if database files are free from physical and logical corruptions.
--The command does not produce backups rather checks the files cn be backed up and are free from --corruptions.
--If the backup validate discovers currupt blocks, then RMAN updates the v$database_block_corruptions --view with the details.
RMAN> backup validate database;
--or a specific file
RMAN> backup validate datafile '+DATA/prod/datafile/example.269.653867209';
--------------------------------------------------------------------------------------------
-- Rman Archival Backup :
--------------------------------------------------------------------------------------------
Allows a self contained backup with all file needed for a recovery that is not removed by rman retention policies.
define the allocate channels allows us to keep the backup in a seperate location.
run {
allocate channel d1 device type disk format '/u01/backup/prac11g/prac11g_%U';
backup as compressed backupset database include current controlfile keep forever tag master_cold_bkup plus archivelog;
}
No comments:
Post a Comment