It’s been more than 4 years since I have had to work with RMAN backup. Previously, sysadmin has been managing database backup using split mirror technology.
Now looking at RMAN from a different angle, calling RMAN scripts from the command line, similar to SQL scripts.
nohup rman @bkupinc0.rman > /dev/null 2>&1 & — Important not to forget @
[oracle@lax:db01]/home/oracle $ nohup rman @bkupinc0.rman > /dev/null 2>&1 & [1] 5643 [oracle@lax:db01]/home/oracle $ [1]+ Done nohup rman @bkupinc0.rman > /dev/null 2>&1 [oracle@lax:db01]/home/oracle $ nohup rman @bkupinc1.rman > /dev/null 2>&1 & [1] 5669 [oracle@lax:db01]/home/oracle $ [1]+ Done nohup rman @bkupinc1.rman > /dev/null 2>&1 [oracle@lax:db01]/home/oracle
Script: bkupinc0.rman
$ cat bkupinc0.rman spool log to bkupinc0.log connect target; show all; # maxopenfiles: ASM/striped 1; else 8 # 1 channel per tape drive for tape backup run { set command id to "INC0"; set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F'; allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.inc0' maxopenfiles 1; backup as compressed backupset incremental level 0 check logical database filesperset 1 tag="INC0" include current controlfile plus archivelog not backed up 1 times filesperset 8 tag="INC0" ; backup spfile tag="INC0"; } exit
rman checksyntax @bad.rman — Must have @ sign
[oracle@lax:db01]/home/oracle $ rman checksyntax @bad.rman Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jun 23 17:20:35 2013 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. RMAN> spool log to bad.log 2> connect target; 3> run { 4> set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F'; 5> allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.bkil0' maxopenfiles 1; 6> backup as compressed backupset 7> incremental level 0 check logical database 8> include controlfile RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "controlfile": expecting one of: "current" RMAN-01007: at line 8 column 9 file: bad.rman
Can also check spool for results.
[oracle@lax:db01]/home/oracle
$ rman checksyntax @bkupinc0.rman
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jun 23 17:20:46 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
RMAN> spool log to bkupinc0.log
2> connect target;
3> show all;
4> # maxopenfiles: ASM/striped 1; else 8
5> # 1 channel per tape drive for tape backup
6> run {
7> set command id to "INC0";
8> set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F';
9> allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.inc0' maxopenfiles 1;
10> backup as compressed backupset
11> incremental level 0 check logical database
12> filesperset 1 tag="INC0"
13> include current controlfile
14> plus archivelog not backed up 1 times
15> filesperset 8 tag="INC0"
16> ;
17> backup spfile tag="INC0";
18> }
19> exit
[oracle@lax:db01]/home/oracle
$ cat bkupinc0.log
The cmdfile has no syntax errors
Recovery Manager complete.
[oracle@lax:db01]/home/oracle
$
I like grouping all backup process into one tag and might get some disagreement on this since I have seen implementation having separate tag for DB, ARC, CF, etc…
If you look at LV column, A=archivelog, 0=incremental level #, F=file backup.
RMAN> list backup summary; using target database control file instead of recovery catalog List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- -------------------- ------- ------- ---------- --- 683 B A A DISK 23-jun-2013 16:20:19 1 1 YES INC0 684 B A A DISK 23-jun-2013 16:20:21 1 1 YES INC0 685 B A A DISK 23-jun-2013 16:20:23 1 1 YES INC0 686 B A A DISK 23-jun-2013 16:20:25 1 1 YES INC0 687 B A A DISK 23-jun-2013 16:20:31 1 1 YES INC0 688 B A A DISK 23-jun-2013 16:20:35 1 1 YES INC0 689 B A A DISK 23-jun-2013 16:20:37 1 1 YES INC0 690 B 0 A DISK 23-jun-2013 16:20:46 1 1 YES INC0 691 B 0 A DISK 23-jun-2013 16:20:56 1 1 YES INC0 692 B 0 A DISK 23-jun-2013 16:21:02 1 1 YES INC0 693 B 0 A DISK 23-jun-2013 16:21:05 1 1 YES INC0 694 B 0 A DISK 23-jun-2013 16:21:06 1 1 YES INC0 695 B 0 A DISK 23-jun-2013 16:21:07 1 1 YES INC0 696 B 0 A DISK 23-jun-2013 16:21:09 1 1 YES INC0 697 B 0 A DISK 23-jun-2013 16:21:10 1 1 YES INC0 698 B 0 A DISK 23-jun-2013 16:21:11 1 1 YES INC0 699 B 0 A DISK 23-jun-2013 16:21:15 1 1 YES INC0 700 B A A DISK 23-jun-2013 16:21:18 1 1 YES INC0 701 B F A DISK 23-jun-2013 16:21:19 1 1 YES INC0 702 B F A DISK 23-jun-2013 16:21:23 1 1 NO TAG20130623T162120 703 B A A DISK 23-jun-2013 16:35:18 1 1 YES INC1 704 B 1 A DISK 23-jun-2013 16:35:19 1 1 YES INC1 705 B 1 A DISK 23-jun-2013 16:35:21 1 1 YES INC1 706 B 1 A DISK 23-jun-2013 16:35:22 1 1 YES INC1 707 B 1 A DISK 23-jun-2013 16:35:23 1 1 YES INC1 708 B 1 A DISK 23-jun-2013 16:35:24 1 1 YES INC1 709 B 1 A DISK 23-jun-2013 16:35:25 1 1 YES INC1 710 B 1 A DISK 23-jun-2013 16:35:27 1 1 YES INC1 711 B 1 A DISK 23-jun-2013 16:35:31 1 1 YES INC1 712 B A A DISK 23-jun-2013 16:35:33 1 1 YES INC1 713 B F A DISK 23-jun-2013 16:35:34 1 1 YES INC1 714 B F A DISK 23-jun-2013 16:35:38 1 1 NO TAG20130623T163536
list backup by file tag inc1;
RMAN> list backup by file tag inc1; List of Datafile Backups ======================== File Key TY LV S Ckp SCN Ckp Time #Pieces #Copies Compressed Tag ---- ------- - -- - ---------- -------------------- ------- ------- ---------- --- 1 704 B 1 A 1398232 23-jun-2013 16:35:19 1 1 YES INC1 2 706 B 1 A 1398235 23-jun-2013 16:35:22 1 1 YES INC1 3 707 B 1 A 1398236 23-jun-2013 16:35:23 1 1 YES INC1 4 705 B 1 A 1398233 23-jun-2013 16:35:20 1 1 YES INC1 5 708 B 1 A 1398238 23-jun-2013 16:35:24 1 1 YES INC1 8 709 B 1 A 1398239 23-jun-2013 16:35:25 1 1 YES INC1 9 710 B 1 A 1398240 23-jun-2013 16:35:26 1 1 YES INC1 List of Archived Log Backups ============================ Thrd Seq Low SCN Low Time BS Key S #Pieces #Copies Compressed Tag ---- ------- ---------- -------------------- ------- - ------- ------- ---------- --- 1 112 1397853 23-jun-2013 16:21:16 703 A 1 1 YES INC1 1 113 1398226 23-jun-2013 16:35:17 712 A 1 1 YES INC1 List of Control File Backups ============================ CF Ckp SCN Ckp Time BS Key S #Pieces #Copies Compressed Tag ---------- -------------------- ------- - ------- ------- ---------- --- 1398241 23-jun-2013 16:35:27 711 A 1 1 YES INC1 List of SPFILE Backups ====================== Modification Time BS Key S #Pieces #Copies Compressed Tag -------------------- ------- - ------- ------- ---------- --- 23-jun-2013 06:00:59 713 A 1 1 YES INC1
Other RMAN scripts
$ cat restore_preview.rman connect target; restore database preview; restore database preview until time 'TRUNC(sysdate)'; [oracle@lax:db01]/home/oracle $ cat validate.rman connect target; backup validate check logical database; restore validate database; restore validate archivelog from time 'sysdate-7'; [oracle@lax:db01]/home/oracle $
