Oracle rman恢复脚本

Oracle rman恢复脚本

𝓓𝓸𝓷 Lv6

Oracle rman时间点恢复脚本

1.restore database
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
RMAN> delete backup;
RMAN> catalog start with '/oracle/rman';

RMAN> run {
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
set newname for database to '/oracle/app/oracle/oradata/emrtest/%b';
set until time "to_date('20250626 18:28:00' , 'yyyymmdd hh24:mi:ss')";
restore database;
switch datafile all;
switch tempfile all;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}



RMAN> run {
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
set newname for database to '/oracle/app/oracle/oradata/emrtest/%b';
set until time "to_date('20250626 18:28:00' , 'yyyymmdd hh24:mi:ss')";
restore database;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}

RMAN> switch database to copy;
2.recover database
1
2
3
4
5
6
7
8
9
10
11
12
RMAN> run {
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
set until time "to_date('20250626 18:28:00' , 'yyyymmdd hh24:mi:ss')";
recover database;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
3.restore archivelog

https://docs.oracle.com/cd/B19306_01/backup.102/b14194/rcmsynta008.htm

1
2
3
4
5
6
7
8
9
10
11
restore archivelog all;   还原全部归档日志文件
restore archivelog from logseq 127912 ; 还原log sequence为127912之后的所有归档日志
restore archivelog from logseq 127912 until logseq 127918; 还原log sequence为127912到127918这几个归档日志
restore archivelog from time 'sysdate-7'; 还原七天以内的归档日志
restore archivelog until logseq 127918; 还原到seqence 为127918的日志文件为止
set archivelog destination to '/data/archivelog/';设定还原日志文件到新路径,

run{
set archivelog destination to '/data/archivelog';
restore archivelog low logseq 127912;
}
  • Title: Oracle rman恢复脚本
  • Author: 𝓓𝓸𝓷
  • Created at : 2025-07-08 16:33:46
  • Updated at : 2025-10-22 09:51:14
  • Link: https://www.zhangdong.me/rman-restore.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
评论