Backup and recovery is required for no dataloss.
We have inconsistent and consistent backups.
If the database is cleanly shutdown (immediate, normal, transactional) .If we take backup this time it is called consistent backup.
If instance fails,we do shut abort,this time if we take backup it is called inconsistent backup.
We take backup in two methods
Rman
User managed backup (OS commands)
Also we can take backup physical backup (datafiles) or logical backup (tables, indexes..etc)
Why we shouldn't add datafiles when online backup is running?
If we add the datafiles when online backup is running that new datafiles it will not added to the backup then backup will become invalid
Archive log apply will only recover dml operations
Database (open)-->archive log-->
Database (closed)-->noarchive log
Database (open)-->noarchive log
**RMAN BACKUP SIZE ESTIMATION AND COMPRESSION**
As taking backup from data files to backup sets it will take only used blocks so we have to estimate the required space as below
SQL> select sum(bytes)/1024/1024/1024 from v$datafile;
SUM(BYTES)/1024/1024/1024
-------------------------
541.294922
SQL> select sum(bytes)/1024/1024/1024 from dba_free_space;
SUM(BYTES)/1024/1024/1024
-------------------------
367.172791
541-367 = 180 GB size of datafiles only it will take
coming to COMPRESSION of backup in RMAN ,iam describing bellow
.(Doc ID 563427.1)
BY default RMAN have the 3 types of compression
1.NULL COMPRESSION
2.UNUSED BLOCK COMPRESSION
3.BINARY COMPRESSION
NULLCOMPRESSION:
RMAN does not back up the contents of data blocks that have never been allocated.
ex||if the table space is having 50GB and we used only 20GB then NULL COMPRESSION will take only 20GB as backup.(eventho few objects(tables) deleted from 20GB but still it will take 20GB as backup
UNUSED BLOCK COMPRESSION:
RMAN will skip the blocks which dont contain data
ex||if the table space is having 50GB and we used only 20GB then NULL COMPRESSION will take only 20GB as backup.(eventho few objects(tables-5GB) deleted from 20GB but still it will take 15GB as backup
BINARY COMPRESSION:
Binary Compression can be done by specifying "AS COMPRESSED" clause in backup command, this compression is called as binary compression.
RMAN can apply a binary compression algorithm as it writes data to backup sets. This compression is similar to the compression provided by many tape vendors when backing up data to tape. But we cannot give exact percentage of compression. This binary compression algorithm can greatly reduce the space required for disk backup storage. It is typically 2x to 4x, and greater for text-intensive databases.
ex||RMAN> backup as compressed backupset database;
SQL> select ALGORITHM_NAME, ALGORITHM_DESCRIPTION, ALGORITHM_COMPATIBILITY from V$RMAN_COMPRESSION_ALGORITHM ;
ALGORITHM_NAME ALGORITHM_DESCRIPTION ALGORITHM_COMPATIB
---------------------------------------------------------------- ---------------------------------------------------------------- ------------------
BZIP2 good compression ratio 9.2.0.0.0
BASIC good compression ratio 9.2.0.0.0
LOW maximum possible compression speed 11.2.0.0.0
ZLIB balance between speed and compression ratio 11.0.0.0.0
MEDIUM balance between speed and compression ratio 11.0.0.0.0
HIGH maximum possible compression ratio 11.2.0.0.0
6 rows selected.
5. Undo Block Compression/Optimization
Starting 11g, RMAN performs undo block optimization. In backup undo optimization, RMAN excludes undo not needed for recovery of a backup, that is, for transactions that have been committed. Undo optimization is only possible if:
- This is a backup set backup
- Full or incremental level 0
- Not a validate
- Backup piece version is 11.0 or above
- User has not disabled undo optimization with:
_undo_block_compression = FALSE
- Backup is going to DISK or OSB tape
- No Guaranteed Restore Point (This check is enabled from 11.2 onwards)
How to recover a datafile if we lost?
through rman
we have to bring database to mount stage
then we have to recover that particular datafile by using the RMAN
What is Target vs Auxilliary vs Catalog?
if you want to create a duplicate of your development database to different host.You can use rman duplicate on the other host where you are creating duplicate database. In this case
Target is your existing development database
Auxiliary is your new database instance where you are going to create database using rman duplicate
catalog is usually a third database where you store backup information of this development database.