Hace unos días encontré una de estas preguntas que vale la pena desarrollar: ¿RMAN comprime respaldos incrementales?. En realidad la pregunta terminó siendo: ¿por qué una estrategia de respaldos incrementales actualizables (o merge incremental backups) no toma en cuenta la compresión en RMAN?.
El camino corto a la respuesta es: sí se comprimen, aunque no todos los archivos generados por RMAN.
Para entender qué se respalda y qué se puede comprimir, voy a desarrollarlo acá con un ejemplo. Pueden ver la respuesta en inglés en el foro de OTN.
Primero, hay que leer la documentación oficial sobre este tipo de respaldos para entender los conceptos: http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmbckba.htm#CHDEHBFF
Luego de revisarla, podemos ver que un respaldo incremental actualizable se basa en una image copy, esto es una copia idéntica de los datafiles que no es posible comprimir con RMAN. A partir del primer respaldo completo incremental (conocido como de nivel 0) se toman respaldos incrementales usados para recuperar el respaldo anterior de nivel 0. Estos respaldos incrementales sí se pueden comprimir con la clausula COMPRESSED en RMAN.
Con un respaldo incremental actualizable se tiene un respaldo completo pronto para usar luego de cada respaldo incremental, sin necesidad de tomar un respaldo completo de la base cada vez.
Aunque esta estrategia parece muy buena, hay que analizar con cuidado si va a ser efectiva para nuestra instalación, ya que un respaldo incremental respalda los bloques que cambiaron desde el último respaldo completo en nivel 0, y por lo tanto puede llegar a ocupar tanto como un respaldo completo (por ejemplo si cambiaron todos los datos). Además agrega overhead por tener que buscar cambios en cada bloque, a menos que se use la funcionalidad de change block tracking (disponible en la versión Enterprise de la base de datos).
A continuación ejemplos. Primero de cómo funciona la compresión en respaldos incrementales, tomando respaldos de un tablespace chico para hacerlo simple.
oracle@oraculo:> sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Wed Aug 15 19:09:03 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
19:10:10 SYS@ent11g>select file_name, bytes/1024/1024 mb
from dba_data_files
where tablespace_name='USERS';
FILE_NAME MB
-------------------------------------- ----------
/u02/oradata/ent11g/users01.dbf 5
19:09:59 SYS@ent11g>col segment_name for a20
19:10:03 SYS@ent11g>col owner for a10
19:10:08 SYS@ent11g> select owner, segment_name, blocks*8/1024 mb
from dba_segments
where tablespace_name='USERS';
OWNER SEGMENT_NAME MB
---------- -------------------- ----------
SCOTT DEPT .0625
SCOTT EMP .0625
SCOTT SALGRADE .0625
SCOTT PK_DEPT .0625
SCOTT PK_EMP .0625
De este tablespace vamos a tomar un respaldo completo de nivel 0 sin compresión:
RMAN> backup incremental level 0 tablespace users;
Starting backup at 15/AUG/2012 19:08:10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:08:12
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:08:15
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp tag=TAG20120815T190811 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 19:08:15
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 23480
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
Ahora respaldamos lo mismo pero comprimido:
RMAN> backup as compressed backupset incremental level 0 tablespace users;
Starting backup at 15/AUG/2012 19:11:35
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:11:36
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:11:37
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp tag=TAG20120815T191135 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15/AUG/2012 19:11:37
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 23480
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
-rw-r----- 1 oracle oinstall 1114112 Aug 15 19:11 o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp
Los respaldos de nivel 0 son completos, por lo tanto ambos tienen los mismos datos, y se puede ver que el comprimido es más chico.
Ahora vamos a tomar un respaldo incremental (nivel 1). Primero sin compresión:
RMAN> backup incremental level 1 tablespace users;
Starting backup at 15/AUG/2012 19:13:08
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:13:09
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:13:10
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_TAG20120815T191308_82r7qog1_.bkp tag=TAG20120815T191308 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15/AUG/2012 19:13:10
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 43160
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
-rw-r----- 1 oracle oinstall 1114112 Aug 15 19:11 o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191308_82r7qog1_.bkp
Y volvemos a respaldar lo mismo, nivel 1, pero comprimido:
RMAN> backup as compressed backupset incremental level 1 tablespace users;
Starting backup at 15/AUG/2012 19:13:33
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:13:33
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:13:34
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_TAG20120815T191333_82r7rg2c_.bkp tag=TAG20120815T191333 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15/AUG/2012 19:13:34
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 43160
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
-rw-r----- 1 oracle oinstall 1114112 Aug 15 19:11 o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191308_82r7qog1_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191333_82r7rg2c_.bkp
Como se puede comprobar, la compresión en este caso no aporta nada, porque no hay datos nuevos.
Modificamos entonces algunos datos para ver realmente la compresión:
19:14:09 SYS@ent11g>create table dummy tablespace users as select * From dba_objects;
Table created.
select owner, segment_name, blocks*8/1024 mb
from dba_segments
where tablespace_name='USERS';
OWNER SEGMENT_NAME MB
---------- -------------------- ----------
SCOTT DEPT .0625
SCOTT EMP .0625
SCOTT SALGRADE .0625
SYS DUMMY 9
SCOTT PK_DEPT .0625
SCOTT PK_EMP .0625
6 rows selected.
Ahora repetimos el respaldo incremental comprimido:
RMAN> backup as compressed backupset incremental level 1 tablespace users;
Starting backup at 15/AUG/2012 19:15:03
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:15:03
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:15:06
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_TAG20120815T191503_82r7v837_.bkp tag=TAG20120815T191503 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 19:15:06
Y podemos comprobar que éste ahora incluye datos porque es mucho más grande que el anterior sin compresión:
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 43160
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
-rw-r----- 1 oracle oinstall 1114112 Aug 15 19:11 o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191308_82r7qog1_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191333_82r7rg2c_.bkp
-rw-r----- 1 oracle oinstall 1966080 Aug 15 19:15 o1_mf_nnnd1_TAG20120815T191503_82r7v837_.bkp
Otro tipo de respaldo incremental es el acumulado (cumulative en inglés). Éste tiene todos los cambios desde el último respaldo en nivel 0, por lo que va a ser más grande que un respaldo diferencial:
RMAN> backup incremental level 1 cumulative tablespace users;
Starting backup at 15/AUG/2012 19:16:25
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:16:26
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:16:29
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_TAG20120815T191625_82r7xtfj_.bkp tag=TAG20120815T191625 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 19:16:29
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 43160
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
-rw-r----- 1 oracle oinstall 1114112 Aug 15 19:11 o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191308_82r7qog1_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191333_82r7rg2c_.bkp
-rw-r----- 1 oracle oinstall 1966080 Aug 15 19:15 o1_mf_nnnd1_TAG20120815T191503_82r7v837_.bkp
-rw-r----- 1 oracle oinstall 8724480 Aug 15 19:16 o1_mf_nnnd1_TAG20120815T191625_82r7xtfj_.bkp
Respaldamos lo mismo pero esta vez con compresión:
RMAN> backup as compressed backupset incremental level 1 cumulative tablespace users;
Starting backup at 15/AUG/2012 19:16:52
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:16:53
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:16:56
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_TAG20120815T191652_82r7yojn_.bkp tag=TAG20120815T191652 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 19:16:56
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
total 43160
-rw-r----- 1 oracle oinstall 1376256 Aug 15 19:08 o1_mf_nnnd0_TAG20120815T190811_82r7gdxj_.bkp
-rw-r----- 1 oracle oinstall 1114112 Aug 15 19:11 o1_mf_nnnd0_TAG20120815T191135_82r7nrkv_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191308_82r7qog1_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:13 o1_mf_nnnd1_TAG20120815T191333_82r7rg2c_.bkp
-rw-r----- 1 oracle oinstall 1966080 Aug 15 19:15 o1_mf_nnnd1_TAG20120815T191503_82r7v837_.bkp
-rw-r----- 1 oracle oinstall 8724480 Aug 15 19:16 o1_mf_nnnd1_TAG20120815T191625_82r7xtfj_.bkp
-rw-r----- 1 oracle oinstall 1966080 Aug 15 19:16 o1_mf_nnnd1_TAG20120815T191652_82r7yojn_.bkp
Cómo se puede ver, este último respaldo tiene los mismos datos que el primer respaldo diferencial después de realizar los cambios en los datos, y es mucho más chico que el otro sin compresión.
Por último, el caso de respaldos incrementales actualizables (merged incremental). Estos son respaldos incrementales nivel 1 que luego se aplican al último respaldo nivel 0 disponible, para generar un nuevo nivel 0 actualizado.
Primero ejemplo, sin compresión:
RMAN> run {
backup incremental level 1 for recover of copy with tag 'BKP_L0' tablespace users;
recover copy of tablespace users with tag 'BKP_L0';
}
Starting backup at 15/AUG/2012 19:18:57
using channel ORA_DISK_1
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
output file name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82r82l9g_.dbf tag=BKP_L0 RECID=1 STAMP=791407138
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 19:19:00
Starting recover at 15/AUG/2012 19:19:01
using channel ORA_DISK_1
no copy of datafile 4 found to recover
Finished recover at 15/AUG/2012 19:19:01
Éste genera un respaldo en nivel 0 aunque le hayamos indicado que sea nivel 1, porque no hay un respaldo nivel 0 de este tipo disponible (for recovery of copy).
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82r82l9g_.dbf
-rw-r----- 1 oracle oinstall 11804672 Aug 15 19:19 /u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82r82l9g_.dbf
Podemos ver que es ídentico al datafile original, porque es una image copy:
oracle@oraculo:~> ls -l /u02/oradata/ent11g/users01.dbf
-rw-r----- 1 oracle oinstall 11804672 Aug 15 19:26 /u02/oradata/ent11g/users01.dbf
Hay que tener presente que las image copy no usan ningún tipo de compresión en RMAN (unused block/free space/binary). Esto es algo que se puede validar fácilmente:
RMAN> backup tablespace users;
Starting backup at 15/AUG/2012 19:26:23
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:26:23
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:26:25
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnndf_TAG20120815T192623_82r8jj6q_.bkp tag=TAG20120815T192623 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 15/AUG/2012 19:26:25
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnndf_TAG20120815T192623_82r8jj6q_.bkp
-rw-r----- 1 oracle oinstall 10059776 Aug 15 19:26 o1_mf_nnndf_TAG20120815T192623_82r8jj6q_.bkp
La siguiente vez que tomamos un respaldo incremental actualizable funciona diferente, porque ahora tiene un respaldo incremental completo (de nivel 0) disponible para actualizar, y por lo tanto puede tomar un respaldo incremental (de nivel 1):
RMAN> run {
backup incremental level 1 for recover of copy with tag 'BKP_L0' tablespace users;
recover copy of tablespace users with tag 'BKP_L0';
}
Starting backup at 15/AUG/2012 19:19:21
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 19:19:21
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 19:19:24
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82r83b3b_.bkp tag=BKP_L0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 19:19:24
Starting recover at 15/AUG/2012 19:19:25
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82r82l9g_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82r83b3b_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82r83b3b_.bkp tag=BKP_L0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 15/AUG/2012 19:19:27
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82r83b3b_.bkp
total 43160
-rw-r----- 1 oracle oinstall 40960 Aug 15 19:19 o1_mf_nnnd1_BKP_L0_82r83b3b_.bkp
Este respaldo fue muy chico porque no hubo actividad en el tablespace desde el respaldo anterior.
Ahora lo que realmente nos interesa ver: ¿que ocurre cuando usamos la opción de compresión con un respaldo incremental actualizable?.
run {
backup as compressed backupset incremental level 1 for recover of copy with tag 'BKPC_L0' tablespace users;
recover copy of tablespace users with tag 'BKPC_L0';
}
RMAN>
Starting backup at 15/AUG/2012 21:35:55
using channel ORA_DISK_1
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
output file name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82rj3gtb_.dbf tag=BKPC_L0 RECID=3 STAMP=791415359
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
Finished backup at 15/AUG/2012 21:36:01
RMAN>
Starting recover at 15/AUG/2012 21:36:03
using channel ORA_DISK_1
no copy of datafile 4 found to recover
Finished recover at 15/AUG/2012 21:36:03
Como fue la primera vez que tomamos uno de este tipo, se hizo un respaldo nivel 0 (el anterior había sido con la etiqueta BKP_L0, ahora es BKPC_L0 y eso lo hace distinto):
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/datafile/
total 23088
-rw-r----- 1 oracle oinstall 11804672 Aug 15 19:19 o1_mf_users_82r82l9g_.dbf
-rw-r----- 1 oracle oinstall 11804672 Aug 15 21:35 o1_mf_users_82rj3gtb_.dbf
La siguiente vez que lo ejecutamos ya vimos que va a tomar un incremental nivel 1:
RMAN> run {
backup as compressed backupset incremental level 1 for recover of copy with tag 'BKPC_L0' tablespace users;
recover copy of tablespace users with tag 'BKPC_L0';
}
Starting backup at 15/AUG/2012 21:49:07
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 21:49:08
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 21:49:11
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjw4fc_.bkp tag=BKPC_L0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 21:49:11
Starting recover at 15/AUG/2012 21:49:11
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82rj3gtb_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjw4fc_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjw4fc_.bkp tag=BKPC_L0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 15/AUG/2012 21:49:13
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjw4fc_.bkp
-rw-r----- 1 oracle oinstall 40960 Aug 15 21:49 o1_mf_nnnd1_BKPC_L0_82rjw4fc_.bkp
Otra vez, al no tener cambios en los datos del tablespace, el respaldo incremental no tiene datos.
Así que para ver la compresión, generamos una tabla con datos y repetimos el respaldo:
21:50:05 SYS@ent11g>create table dummy tablespace users as select * From dba_objects;
Table created.
Elapsed: 00:00:04.98
RMAN> run {
backup as compressed backupset incremental level 1 for recover of copy with tag 'BKPC_L0' tablespace users;
recover copy of tablespace users with tag 'BKPC_L0';
}
2> 3> 4>
Starting backup at 15/AUG/2012 21:50:34
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 21:50:34
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 21:50:38
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjyvdb_.bkp tag=BKPC_L0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 15/AUG/2012 21:50:38
Starting recover at 15/AUG/2012 21:50:38
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82rj3gtb_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjyvdb_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjyvdb_.bkp tag=BKPC_L0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished recover at 15/AUG/2012 21:50:42
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKPC_L0_82rjyvdb_.bkp
-rw-r----- 1 oracle oinstall 1966080 Aug 15 21:50 o1_mf_nnnd1_BKPC_L0_82rjyvdb_.bkp
Ahora sí tenemos un respaldo con datos, y podemos comparar cuánto ocupa el mismo respaldo sin compresión. Repitiendo el mismo respaldo incremental anterior BKP_L0 tendríamos los mismos cambios, ya que ese usa otra image copy para recuperar (no es el BKPC_L0 que usamos ahora).
Para evitar dudas, tomo un nuevo respaldo incremental y repito las sentencias de drop/create table para tener los mismos cambios que en el respaldo anterior:
-- Respaldo:
RMAN> run {
backup incremental level 1 for recover of copy with tag 'BKP_L0' tablespace users;
recover copy of tablespace users with tag 'BKP_L0';
}
RMAN>
Starting backup at 15/AUG/2012 21:51:37
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 21:51:37
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 21:51:40
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82rk0t3h_.bkp tag=BKP_L0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 21:51:40
RMAN>
Starting recover at 15/AUG/2012 21:51:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82r82l9g_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82rk0t3h_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82rk0t3h_.bkp tag=BKP_L0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished recover at 15/AUG/2012 21:51:49
-- Genero cambios:
21:51:11 SYS@ent11g>drop table dummy;
Table dropped.
Elapsed: 00:00:01.27
21:52:02 SYS@ent11g>create table dummy tablespace users as select * From dba_objects;
Table created.
-- Respaldo de nuevo:
RMAN> run {
backup incremental level 1 for recover of copy with tag 'BKP_L0' tablespace users;
recover copy of tablespace users with tag 'BKP_L0';
}2> 3> 4>
Starting backup at 15/AUG/2012 21:52:22
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/ent11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15/AUG/2012 21:52:23
channel ORA_DISK_1: finished piece 1 at 15/AUG/2012 21:52:26
piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82rk280f_.bkp tag=BKP_L0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15/AUG/2012 21:52:26
Starting recover at 15/AUG/2012 21:52:26
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/u01/app/oracle/fast_recovery_area/ENT11G/datafile/o1_mf_users_82r82l9g_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82rk280f_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15/o1_mf_nnnd1_BKP_L0_82rk280f_.bkp tag=BKP_L0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 15/AUG/2012 21:52:28
-- veo los archivos generados por el respaldo incremental:
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/backupset/2012_08_15
-rw-r----- 1 oracle oinstall 1966080 Aug 15 21:50 o1_mf_nnnd1_BKPC_L0_82rjyvdb_.bkp
-rw-r----- 1 oracle oinstall 9707520 Aug 15 21:51 o1_mf_nnnd1_BKP_L0_82rk0t3h_.bkp
-rw-r----- 1 oracle oinstall 8732672 Aug 15 21:52 o1_mf_nnnd1_BKP_L0_82rk280f_.bkp
-- veo los archivos generados por el respaldo image copy:
oracle@oraculo:~> ls -lrt /u01/app/oracle/fast_recovery_area/ENT11G/datafile/ &
total 23088
-rw-r----- 1 oracle oinstall 11804672 Aug 15 19:19 o1_mf_users_82r82l9g_.dbf
-rw-r----- 1 oracle oinstall 11804672 Aug 15 21:49 o1_mf_users_82rj3gtb_.dbf
Como se puede ver, solo el respaldo incremental (level 1) se comprime.
Fue un ejemplo largo, pero tiene todo lo necesario para entender la compresión con respaldos incrementales en todas sus variantes.
Un saludo.
No hay comentarios.:
Publicar un comentario