A. Backup using RMAN
1. Backup Database + plus archivelog
backup database plus archivelog;
RMAN> backup database plus archivelog;
Starting backup at 24-DEC-24
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=50 RECID=1 STAMP=1188492501
input archived log thread=1 sequence=51 RECID=2 STAMP=1188492563
input archived log thread=1 sequence=52 RECID=3 STAMP=1188492609
input archived log thread=1 sequence=53 RECID=4 STAMP=1188492871
input archived log thread=1 sequence=54 RECID=5 STAMP=1188492941
input archived log thread=1 sequence=55 RECID=6 STAMP=1188493009
input archived log thread=1 sequence=56 RECID=7 STAMP=1188493163
input archived log thread=1 sequence=57 RECID=8 STAMP=1188493230
input archived log thread=1 sequence=58 RECID=9 STAMP=1188551567
input archived log thread=1 sequence=59 RECID=10 STAMP=1188553084
input archived log thread=1 sequence=60 RECID=11 STAMP=1188553084
input archived log thread=1 sequence=61 RECID=12 STAMP=1188553322
input archived log thread=1 sequence=62 RECID=13 STAMP=1188553322
input archived log thread=1 sequence=63 RECID=14 STAMP=1188553452
input archived log thread=1 sequence=64 RECID=15 STAMP=1188553452
input archived log thread=1 sequence=65 RECID=16 STAMP=1188553775
input archived log thread=1 sequence=66 RECID=17 STAMP=1188553775
input archived log thread=1 sequence=67 RECID=18 STAMP=1188555260
channel ORA_DISK_1: starting piece 1 at 24-DEC-24
channel ORA_DISK_1: finished piece 1 at 24-DEC-24
piece handle=/home/oracle/backuprman/163dfqfs_1_1 tag=TAG20241224T101420 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 24-DEC-24
Starting backup at 24-DEC-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/TGH/sysaux01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/TGH/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/TGH/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/TGH/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-DEC-24
channel ORA_DISK_1: finished piece 1 at 24-DEC-24
piece handle=/home/oracle/backuprman/173dfqfv_1_1 tag=TAG20241224T101423 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 24-DEC-24
Starting backup at 24-DEC-24
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=68 RECID=19 STAMP=1188555328
channel ORA_DISK_1: starting piece 1 at 24-DEC-24
channel ORA_DISK_1: finished piece 1 at 24-DEC-24
piece handle=/home/oracle/backuprman/183dfqi0_1_1 tag=TAG20241224T101528 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-DEC-24
Starting Control File and SPFILE Autobackup at 24-DEC-24
piece handle=/home/oracle/backuprman/c-3319278558-20241224-06 comment=NONE
Finished Control File and SPFILE Autobackup at 24-DEC-24
RMAN>
2. check file backup
[oracle@teguhth backuprman]$ pwd
/home/oracle/backuprman
[oracle@teguhth backuprman]$ ls
163dfqfs_1_1 173dfqfv_1_1 183dfqi0_1_1 c-3319278558-20241224-06
[oracle@teguhth backuprman]$
B. Restore database using RMAN
Untuk me-restore database menggunakan RMAN dari backup seperti yang Anda tunjukkan, berikut langkah-langkahnya:
capture before restore
1. Backup Database + plus archivelog
backup database plus archivelog;
RMAN> backup database plus archivelog;
Starting backup at 24-DEC-24
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=50 RECID=1 STAMP=1188492501
input archived log thread=1 sequence=51 RECID=2 STAMP=1188492563
input archived log thread=1 sequence=52 RECID=3 STAMP=1188492609
input archived log thread=1 sequence=53 RECID=4 STAMP=1188492871
input archived log thread=1 sequence=54 RECID=5 STAMP=1188492941
input archived log thread=1 sequence=55 RECID=6 STAMP=1188493009
input archived log thread=1 sequence=56 RECID=7 STAMP=1188493163
input archived log thread=1 sequence=57 RECID=8 STAMP=1188493230
input archived log thread=1 sequence=58 RECID=9 STAMP=1188551567
input archived log thread=1 sequence=59 RECID=10 STAMP=1188553084
input archived log thread=1 sequence=60 RECID=11 STAMP=1188553084
input archived log thread=1 sequence=61 RECID=12 STAMP=1188553322
input archived log thread=1 sequence=62 RECID=13 STAMP=1188553322
input archived log thread=1 sequence=63 RECID=14 STAMP=1188553452
input archived log thread=1 sequence=64 RECID=15 STAMP=1188553452
input archived log thread=1 sequence=65 RECID=16 STAMP=1188553775
input archived log thread=1 sequence=66 RECID=17 STAMP=1188553775
input archived log thread=1 sequence=67 RECID=18 STAMP=1188555260
channel ORA_DISK_1: starting piece 1 at 24-DEC-24
channel ORA_DISK_1: finished piece 1 at 24-DEC-24
piece handle=/home/oracle/backuprman/163dfqfs_1_1 tag=TAG20241224T101420 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 24-DEC-24
Starting backup at 24-DEC-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/TGH/sysaux01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/TGH/system01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/TGH/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/TGH/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-DEC-24
channel ORA_DISK_1: finished piece 1 at 24-DEC-24
piece handle=/home/oracle/backuprman/173dfqfv_1_1 tag=TAG20241224T101423 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 24-DEC-24
Starting backup at 24-DEC-24
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=68 RECID=19 STAMP=1188555328
channel ORA_DISK_1: starting piece 1 at 24-DEC-24
channel ORA_DISK_1: finished piece 1 at 24-DEC-24
piece handle=/home/oracle/backuprman/183dfqi0_1_1 tag=TAG20241224T101528 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-DEC-24
Starting Control File and SPFILE Autobackup at 24-DEC-24
piece handle=/home/oracle/backuprman/c-3319278558-20241224-06 comment=NONE
Finished Control File and SPFILE Autobackup at 24-DEC-24
RMAN>
2. check file backup
[oracle@teguhth backuprman]$ pwd
/home/oracle/backuprman
[oracle@teguhth backuprman]$ ls
163dfqfs_1_1 173dfqfv_1_1 183dfqi0_1_1 c-3319278558-20241224-06
[oracle@teguhth backuprman]$
B. Restore database using RMAN
Untuk me-restore database menggunakan RMAN dari backup seperti yang Anda tunjukkan, berikut langkah-langkahnya:
capture before restore
select tname,tabtype,clusterid,(SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') AS CURRENT_SCHEMA FROM DUAL) as Schema from tab
1. Persiapan Restore
Pastikan semua file backup yang diperlukan ada di lokasi yang sesuai dengan yang digunakan saat backup (/home/oracle/backuprman/).
Pastikan Oracle Database dalam mode nomount atau mount tergantung pada jenis restore.
Command untuk masuk ke RMAN:
rman target /
2. Restoring Database
2.1 Jika Anda ingin restore seluruh database:
2.1 Set Database ke Mode NOMOUNT: Jalankan dari SQL*Plus atau RMAN:
SHUTDOWN IMMEDIATE;
STARTUP NOMOUNT;
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> STARTUP NOMOUNT;
ORACLE instance started.
Total System Global Area 566229384 bytes
Fixed Size 8898952 bytes
Variable Size 528482304 bytes
Database Buffers 25165824 bytes
Redo Buffers 3682304 bytes
SQL>
2.2 Restore Control File:
rman
RESTORE CONTROLFILE FROM '/home/oracle/backuprman/c-3319278558-20241224-06';
[oracle@teguhth ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Dec 24 13:33:55 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TGH (not mounted)
RMAN>
RMAN> RESTORE CONTROLFILE FROM '/home/oracle/backuprman/c-3319278558-20241224-06';
Starting restore at 24-DEC-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=428 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/TGH/control01.ctl
output file name=/u01/app/oracle/oradata/TGH/control02.ctl
Finished restore at 24-DEC-24
RMAN>
2.3 Mount Database:
rman
ALTER DATABASE MOUNT;
RMAN> ALTER DATABASE MOUNT;
released channel: ORA_DISK_1
Statement processed
RMAN>
2.4 Restore Database: Jalankan perintah ini di RMAN:
rman
RESTORE DATABASE;
RMAN> RESTORE DATABASE;
Starting restore at 24-DEC-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=428 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/TGH/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/TGH/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/TGH/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/TGH/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backuprman/173dfqfv_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backuprman/173dfqfv_1_1 tag=TAG20241224T101423
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:38
Finished restore at 24-DEC-24
RMAN>
2.5 Recover Database: Gunakan archive log yang telah dibackup untuk melakukan recovery:
rman
RECOVER DATABASE;
RMAN> RECOVER DATABASE;
Starting recover at 24-DEC-24
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 68 is already on disk as file /u01/app/oracle/oradata/TGH/redo02.log
archived log for thread 1 with sequence 69 is already on disk as file /u01/app/oracle/oradata/TGH/redo03.log
archived log file name=/u01/app/oracle/oradata/TGH/redo02.log thread=1 sequence=68
archived log file name=/u01/app/oracle/oradata/TGH/redo03.log thread=1 sequence=69
media recovery complete, elapsed time: 00:00:00
Finished recover at 24-DEC-24
RMAN>
2.6 Open Database: Setelah recovery selesai, buka database:
rman
ALTER DATABASE OPEN RESETLOGS;
RMAN> ALTER DATABASE OPEN RESETLOGS;
Statement processed
RMAN>
2.7 after restore
3. Jika Anda hanya ingin restore tablespace atau datafile tertentu:
3.1 Mount Database (jika belum):
rman
ALTER DATABASE MOUNT;
Restore Tablespace/Datafile: Misalnya untuk tablespace USERS:
rman
SELECT file_name, status
FROM dba_data_files
WHERE file_name = '/u01/app/oracle/oradata/TGH/users01.dbf';
ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/TGH/users01.dbf' OFFLINE;
RESTORE TABLESPACE USERS;
RMAN> RESTORE TABLESPACE USERS;
Starting restore at 24-DEC-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/TGH/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backuprman/173dfqfv_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backuprman/173dfqfv_1_1 tag=TAG20241224T101423
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 24-DEC-24
RMAN>
Atau untuk datafile tertentu:
RESTORE DATAFILE '/u01/app/oracle/oradata/TGH/users01.dbf';
RMAN> RESTORE DATAFILE '/u01/app/oracle/oradata/TGH/users01.dbf';
Starting restore at 24-DEC-24
using channel ORA_DISK_1
skipping datafile 7; already restored to file /u01/app/oracle/oradata/TGH/users01.dbf
restore not done; all files read only, offline, excluded, or already restored
Finished restore at 24-DEC-24
RMAN>
Recover Tablespace/Datafile: Jalankan perintah recovery untuk memastikan konsistensi:
RECOVER TABLESPACE USERS;
RMAN> RECOVER TABLESPACE USERS;
Starting recover at 24-DEC-24
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 68 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_68_1183304545.dbf
archived log for thread 1 with sequence 69 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_69_1183304545.dbf
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_1_1188568972.dbf
archived log file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_68_1183304545.dbf thread=1 sequence=68
archived log file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_69_1183304545.dbf thread=1 sequence=69
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-DEC-24
RMAN>
Atau:
RECOVER DATAFILE '/u01/app/oracle/oradata/TGH/users01.dbf';
RMAN> RECOVER DATAFILE '/u01/app/oracle/oradata/TGH/users01.dbf';
Starting recover at 24-DEC-24
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 24-DEC-24
RMAN>
2.3 Jika Anda ingin restore archive log saja:
Gunakan perintah berikut untuk me-restore archive log:
rman
RESTORE ARCHIVELOG ALL;
Atau untuk archive log tertentu berdasarkan waktu:
rman
RESTORE ARCHIVELOG FROM TIME 'SYSDATE-1';
RMAN> RESTORE ARCHIVELOG ALL;
Starting restore at 24-DEC-24
using channel ORA_DISK_1
archived log for thread 1 with sequence 50 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_50_1183304545.dbf
archived log for thread 1 with sequence 51 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_51_1183304545.dbf
archived log for thread 1 with sequence 52 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_52_1183304545.dbf
archived log for thread 1 with sequence 53 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_53_1183304545.dbf
archived log for thread 1 with sequence 54 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_54_1183304545.dbf
archived log for thread 1 with sequence 55 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_55_1183304545.dbf
archived log for thread 1 with sequence 56 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_56_1183304545.dbf
archived log for thread 1 with sequence 57 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_57_1183304545.dbf
archived log for thread 1 with sequence 58 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_58_1183304545.dbf
archived log for thread 1 with sequence 59 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_59_1183304545.dbf
archived log for thread 1 with sequence 60 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_60_1183304545.dbf
archived log for thread 1 with sequence 61 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_61_1183304545.dbf
archived log for thread 1 with sequence 62 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_62_1183304545.dbf
archived log for thread 1 with sequence 63 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_63_1183304545.dbf
archived log for thread 1 with sequence 64 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_64_1183304545.dbf
archived log for thread 1 with sequence 65 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_65_1183304545.dbf
archived log for thread 1 with sequence 66 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_66_1183304545.dbf
archived log for thread 1 with sequence 67 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_67_1183304545.dbf
archived log for thread 1 with sequence 68 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_68_1183304545.dbf
restore not done; all files read only, offline, excluded, or already restored
Finished restore at 24-DEC-24
RMAN> RESTORE ARCHIVELOG FROM TIME 'SYSDATE-1';
Starting restore at 24-DEC-24
using channel ORA_DISK_1
archived log for thread 1 with sequence 50 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_50_1183304545.dbf
archived log for thread 1 with sequence 51 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_51_1183304545.dbf
archived log for thread 1 with sequence 52 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_52_1183304545.dbf
archived log for thread 1 with sequence 53 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_53_1183304545.dbf
archived log for thread 1 with sequence 54 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_54_1183304545.dbf
archived log for thread 1 with sequence 55 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_55_1183304545.dbf
archived log for thread 1 with sequence 56 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_56_1183304545.dbf
archived log for thread 1 with sequence 57 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_57_1183304545.dbf
archived log for thread 1 with sequence 58 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_58_1183304545.dbf
archived log for thread 1 with sequence 59 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_59_1183304545.dbf
archived log for thread 1 with sequence 60 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_60_1183304545.dbf
archived log for thread 1 with sequence 61 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_61_1183304545.dbf
archived log for thread 1 with sequence 62 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_62_1183304545.dbf
archived log for thread 1 with sequence 63 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_63_1183304545.dbf
archived log for thread 1 with sequence 64 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_64_1183304545.dbf
archived log for thread 1 with sequence 65 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_65_1183304545.dbf
archived log for thread 1 with sequence 66 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_66_1183304545.dbf
archived log for thread 1 with sequence 67 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_67_1183304545.dbf
archived log for thread 1 with sequence 68 is already on disk as file /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch1_68_1183304545.dbf
restore not done; all files read only, offline, excluded, or already restored
Finished restore at 24-DEC-24
RMAN>
3. Verifikasi Restore
Setelah restore, pastikan:
Database dapat dibuka dan berjalan normal.
File yang direstore sesuai dengan kebutuhan Anda.
No comments:
Post a Comment