Oracle yedek almak için bir araç kullanır.
Bu araç RMAN olarak isimlendirilir. RMAN açılımı Recovery Manager’dır.
RMAN yedek alma ile ilgili işlemleri otomatize bir halde sunar.Arka planda bir çok işlemi kendisi halleder.
Örneğin tablespacelerin backup mode alınması sonrasında normal mode alınması gibi işlemleri kendisi halleder.
Bunlara ek olarak, Control File, Spfile, Arşiv logları alabildiğimiz gibi, bütün bu işlemleri RMAN ile otomatik hale getirebiliriz.
RMAN ile yedek alabilmek için veri tabanının ARCHIVELOG modunda olması gerekmektedir
Şimdi gelin rman ile oracle veri tabanı yedeğimizi alalım. Bu işlemlere yaparken incelemelerde bulunalım.
Aşağıdaki komutu işletim sistemi üzerinde kullanarak recovery manager’a (RMAN) girişimizi sağlıyoruz.
[oracle@server admin]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Feb 1 10:31:45 2022
Version 19.13.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2391253514)
Eğer işletim sisteminde kurulu Oracle veri tabanı birden fazla yada doğru veri tabanı üzerindemiyim’i netleştirmek isterseniz.
[oracle@server admin]$ rman target user/pass@TEST
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Feb 1 10:07:53 2022
Version 19.13.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2391253514)
Buradaki TEST parametresini tnsnames.ora dosyasındaki tns bilgisinden alarak erişimi sağlıyor.
Şimdi oracle veri tabanında alınan yedeklerin türlerine bakalım.
1-Cold Backup: Veri tabanını kapatıp sonrasında veri tabanını mount mode alarak işlemi yaparız.
2-Hot(Online Backup): Veri tabanı açıkken ,kullanıcılar sisteme erişim halindeyken alınan bir yedek türüdür.
3-Incremental Backup: Incremental backup alınırken, veri tabanında değişen tüm veriler önceki yedek üzerine eklenir.
Böylece veri tabanında yedek alma süresi önemli ölçüde azaltmış oluruz.
4-Full Backup: Veri tabanında yer alan tüm dosyaların yedeklenmesidir. Normal Backup olarak da bilinir.
Şimdi gelin Cold Backup alalım.
Aşağıdaki komutları sırasıyla kullanacağız.
rman target /
shutdown immediate;
startup mount;
backup database format ‘/orahome/backup/%d_%t_%s.rman’; (backup database; bu komuta ek olarak bizi hangi dizine alacağını belirttik.)
alter database open;
[oracle@server admin]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Feb 1 10:31:45 2022
Version 19.13.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2391253514)
RMAN> select round(sum(bytes)/1024/1024/1024,2) as "total db size in gb",sysdate from dba_data_files;
using target database control file instead of recovery catalog
total db size in gb SYSDATE
------------------- ---------
2.13 01-FEB-22
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 771748528 bytes
Fixed Size 8901296 bytes
Variable Size 641728512 bytes
Database Buffers 113246208 bytes
Redo Buffers 7872512 bytes
RMAN> backup database format '/orahome/backup/%d_%t_%s.rman';
Starting backup at 01-FEB-22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=253 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/orahome/app/oradata/TEST/datafile/o1_mf_system_jx8n47tn_.dbf
input datafile file number=00003 name=/orahome/app/oradata/TEST/datafile/o1_mf_sysaux_jx8n51bz_.dbf
input datafile file number=00004 name=/orahome/app/oradata/TEST/datafile/o1_mf_undotbs1_jx8n5jmp_.dbf
input datafile file number=00007 name=/orahome/app/oradata/TEST/datafile/o1_mf_users_jx8n5ksr_.dbf
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/backup/TEST_1095503904_1.rman tag=TAG20220201T103824 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095503540_jzkrvqdh_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
RMAN> alter database open;
Statement processed
RMAN> exit
Recovery Manager complete.
Şimdi belirttiğimiz dizine gidip kontrol edelim.
[oracle@server ~]$ cd /orahome/backup/
[oracle@server backup]$ ll
total 1424984
-rw-r----- 1 oracle oinstall 1459183616 Feb 1 10:38 TEST_1095503904_1.rman
Şimdi Hot Backup alalım.
[oracle@server admin]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Feb 1 11:42:36 2022
Version 19.13.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2391253514)
RMAN> backup database format '/orahome/backup/%d_%t_%s.rman';
Starting backup at 01-FEB-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=274 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/orahome/app/oradata/TEST/datafile/o1_mf_system_jx8n47tn_.dbf
input datafile file number=00003 name=/orahome/app/oradata/TEST/datafile/o1_mf_sysaux_jx8n51bz_.dbf
input datafile file number=00004 name=/orahome/app/oradata/TEST/datafile/o1_mf_undotbs1_jx8n5jmp_.dbf
input datafile file number=00007 name=/orahome/app/oradata/TEST/datafile/o1_mf_users_jx8n5ksr_.dbf
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/backup/TEST_1095507772_3.rman tag=TAG20220201T114252 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095507779_jzkwnms5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
Dizine gidip kontrol ettiğimizde görebiliriz.
Şimdi gelin Full Backup alalım.
RMAN> backup incremental level=0 database;
Starting backup at 01-FEB-22
using channel ORA_DISK_1
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=00001 name=/orahome/app/oradata/TEST/datafile/o1_mf_system_jx8n47tn_.dbf
input datafile file number=00003 name=/orahome/app/oradata/TEST/datafile/o1_mf_sysaux_jx8n51bz_.dbf
input datafile file number=00004 name=/orahome/app/oradata/TEST/datafile/o1_mf_undotbs1_jx8n5jmp_.dbf
input datafile file number=00007 name=/orahome/app/oradata/TEST/datafile/o1_mf_users_jx8n5ksr_.dbf
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/backupset/2022_02_01/o1_mf_nnnd0_TAG20220201T160026_jzlcqbyw_.bkp tag=TAG20220201T160026 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095523233_jzlcql3q_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
Dizin belirtmediğimiz için yedek için set edilen dizine aldıığını görüyoruz.
Son olarakta incremental backup alalım.
RMAN> backup incremental level=1 database;
Starting backup at 01-FEB-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=00001 name=/orahome/app/oradata/TEST/datafile/o1_mf_system_jx8n47tn_.dbf
input datafile file number=00003 name=/orahome/app/oradata/TEST/datafile/o1_mf_sysaux_jx8n51bz_.dbf
input datafile file number=00004 name=/orahome/app/oradata/TEST/datafile/o1_mf_undotbs1_jx8n5jmp_.dbf
input datafile file number=00007 name=/orahome/app/oradata/TEST/datafile/o1_mf_users_jx8n5ksr_.dbf
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/backupset/2022_02_01/o1_mf_nnnd1_TAG20220201T160837_jzld6otj_.bkp tag=TAG20220201T160837 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095523724_jzld6wz0_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
Şimdi incremental ve full backup bulunduğu dizene gidelim.
[oracle@server dbs]$ cd /orahome/app/fast_recovery_area/TEST/backupset/2022_02_01/
[oracle@server 2022_02_01]$ ls -ltr
total 1437000
-rw-r----- 1 oracle oinstall 1465810944 Feb 1 16:00 o1_mf_nnnd0_TAG20220201T160026_jzlcqbyw_.bkp
-rw-r----- 1 oracle oinstall 5677056 Feb 1 16:08 o1_mf_nnnd1_TAG20220201T160837_jzld6otj_.bkp
Boyut olarak aradaki farkı görüyoruz. Full backup sonrası, veri tabanında yapılan değişim kadar backup aldı.
Yukarıdaki örneklerde veri tabanı içerisinde yer al alan tüm nesne ve file’lar için işlem yaptık.
Şimdi nesneleri ve file’ları ayrı ayrı almak için örnekleme yapalım.
System ve Users tablespacelerin yedeğini alalım.
RMAN> backup tablespace system, users;
Starting backup at 01-FEB-22
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=00001 name=/orahome/app/oradata/TEST/datafile/o1_mf_system_jx8n47tn_.dbf
input datafile file number=00007 name=/orahome/app/oradata/TEST/datafile/o1_mf_users_jx8n5ksr_.dbf
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/backupset/2022_02_01/o1_mf_nnndf_TAG20220201T162631_jzlf878y_.bkp tag=TAG20220201T162631 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095524798_jzlf8ghn_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
oracle@server 2022_02_01]$ ls -ltr
total 2329536
-rw-r----- 1 oracle oinstall 1465810944 Feb 1 16:00 o1_mf_nnnd0_TAG20220201T160026_jzlcqbyw_.bkp
-rw-r----- 1 oracle oinstall 5677056 Feb 1 16:08 o1_mf_nnnd1_TAG20220201T160837_jzld6otj_.bkp
-rw-r----- 1 oracle oinstall 913956864 Feb 1 16:26 o1_mf_nnndf_TAG20220201T162631_jzlf878y_.bkp
Kontrol ettiğimizde ilgili dosyayı görüyoruz.
Arşiv dosyalarını yedeklemek.
RMAN> BACKUP ARCHIVELOG ALL;
Starting backup at 01-FEB-22
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=15 RECID=1 STAMP=1095525722
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/backupset/2022_02_01/o1_mf_annnn_TAG20220201T164202_jzlg5bk0_.bkp tag=TAG20220201T164202 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095525723_jzlg5cqk_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
[oracle@server 2022_02_01]$ ls -ltr
total 2388544
-rw-r----- 1 oracle oinstall 1465810944 Feb 1 16:00 o1_mf_nnnd0_TAG20220201T160026_jzlcqbyw_.bkp
-rw-r----- 1 oracle oinstall 5677056 Feb 1 16:08 o1_mf_nnnd1_TAG20220201T160837_jzld6otj_.bkp
-rw-r----- 1 oracle oinstall 913956864 Feb 1 16:26 o1_mf_nnndf_TAG20220201T162631_jzlf878y_.bkp
-rw-r----- 1 oracle oinstall 60422656 Feb 1 16:42 o1_mf_annnn_TAG20220201T164202_jzlg5bk0_.bkp
Control file yedeklemek.
RMAN ile backup alırken, bazı dosyaların (örneğin controlfile ya da spfile gibi) otomatik olarak yedek
alınmasını sağlayabilirsiniz. Aşağıdaki gibi bir giriş yaptığınız takdirde RMAN ile alınan her yedek
esnasında, control file da yedeklenecektir.
RMAN> CONFIGURE CONTROLFILE ATUOBACKUP ON;
Yalnız yedeklendiği klasör $ORACLE_HOME/dbs şeklinde olacaktır. Yedeklerinizi doğal olarak farklı bir ortamda tutmak isteyebilirsiniz. Farklı bir konum için aşağıdaki gibi belirtmeniz gerekir.
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/data2/backup/cf_%F.rman';
Dilerseniz manuel anlık bir backup almanız da mümkündür
RMAN> BACKUP CURRENT CONTROLFILE;
Starting backup at 01-FEB-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 01-FEB-22
channel ORA_DISK_1: finished piece 1 at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/backupset/2022_02_01/o1_mf_ncnnf_TAG20220201T164421_jzlg9q0v_.bkp tag=TAG20220201T164421 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 01-FEB-22
Starting Control File and SPFILE Autobackup at 01-FEB-22
piece handle=/orahome/app/fast_recovery_area/TEST/autobackup/2022_02_01/o1_mf_s_1095525864_jzlg9r6w_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-22
[oracle@server 2022_02_01]$ ls -ltr
total 2398976
-rw-r----- 1 oracle oinstall 1465810944 Feb 1 16:00 o1_mf_nnnd0_TAG20220201T160026_jzlcqbyw_.bkp
-rw-r----- 1 oracle oinstall 5677056 Feb 1 16:08 o1_mf_nnnd1_TAG20220201T160837_jzld6otj_.bkp
-rw-r----- 1 oracle oinstall 913956864 Feb 1 16:26 o1_mf_nnndf_TAG20220201T162631_jzlf878y_.bkp
-rw-r----- 1 oracle oinstall 60422656 Feb 1 16:42 o1_mf_annnn_TAG20220201T164202_jzlg5bk0_.bkp
-rw-r----- 1 oracle oinstall 10682368 Feb 1 16:44 o1_mf_ncnnf_TAG20220201T164421_jzlg9q0v_.bkp
Aldığınız yedeklerin içinde otomatik alındığına dikkat etmeniz yeterli.