@@ -17,21 +17,52 @@ rmantmpfile2=${logfileformat}.rman.tmp2
17
17
# need to get the new file name from the string
18
18
# output file name=+NEW_DG/<db_unique_name>/datafile/my_ts.1097.923044943 tag=TAG20160920T092223 RECID=5 STAMP=923044953
19
19
20
+
20
21
cat $file_list_file | while read datafile
21
22
do
22
23
23
- # First do rman copy datafile
24
+ echo " INFO - Backup as copy of $ datafile"
24
25
rman target sys/password << EOF > $rmantmpfile1
25
26
BACKUP AS COPY DATAFILE "${datafile} " FORMAT "+${to_diskgroup} ";
26
27
EOF
27
28
29
+ if (grep RMAN- $rmantmpfile1 )
30
+ then
31
+ echo " ERR - Error in backup-as-copy step for ${datafile} "
32
+ echo " Look in $rmantmpfile1 (contents below)"
33
+ cat $rmantmpfile1
34
+ exit 1
35
+ fi
36
+
37
+ datafilecopy=` grep " output file name" $rmantmpfile1 | awk ' {print $3}' | cut -d= -f2`
28
38
29
- rman target sys/password << EOF
39
+ echo " INFO - Switch and recover file $datafilecopy - copy of $datafile "
40
+ rman target sys/password << EOF > $rmantmpfile2
30
41
SQL "ALTER DATABASE DATAFILE ''${datafile} '' OFFLINE";
31
42
SWITCH DATAFILE "${datafile} " TO COPY;
32
43
RECOVER DATAFILE "${datafilecopy} ";
33
44
SQL "ALTER DATABASE DATAFILE ''${datafilecopy} '' ONLINE";
45
+ EOF
46
+
47
+ if (grep RMAN- $rmantmpfile2 )
48
+ then
49
+ echo " ERR - Error in backup-as-copy step for ${datafile} "
50
+ echo " Look in $rmantmpfile2 (contents below)"
51
+ cat $rmantmpfile2
52
+ exit 1
53
+ fi
54
+
55
+ echo " INFO - Delete file $datafile "
56
+ rman target sys/password << EOF > $rmantmpfile3
34
57
DELETE DATAFILECOPY "${datafile} ";
35
58
EOF
36
59
60
+ if (grep RMAN- $rmantmpfile3 )
61
+ then
62
+ echo " ERR - Error in backup-as-copy step for ${datafile} "
63
+ echo " Look in $rmantmpfile3 (contents below)"
64
+ cat $rmantmpfile2
65
+ exit 1
66
+ fi
67
+
37
68
done
0 commit comments