Skip to content

Commit 4c81ff7

Browse files
authored
Update asm-copy-file-with-rman.sh
1 parent b7a26dd commit 4c81ff7

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

asm-copy-file-with-rman.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,52 @@ rmantmpfile2=${logfileformat}.rman.tmp2
1717
# need to get the new file name from the string
1818
# output file name=+NEW_DG/<db_unique_name>/datafile/my_ts.1097.923044943 tag=TAG20160920T092223 RECID=5 STAMP=923044953
1919

20+
2021
cat $file_list_file | while read datafile
2122
do
2223

23-
# First do rman copy datafile
24+
echo "INFO - Backup as copy of $datafile"
2425
rman target sys/password <<EOF > $rmantmpfile1
2526
BACKUP AS COPY DATAFILE "${datafile}" FORMAT "+${to_diskgroup}";
2627
EOF
2728

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`
2838

29-
rman target sys/password <<EOF
39+
echo "INFO - Switch and recover file $datafilecopy - copy of $datafile"
40+
rman target sys/password <<EOF > $rmantmpfile2
3041
SQL "ALTER DATABASE DATAFILE ''${datafile}'' OFFLINE";
3142
SWITCH DATAFILE "${datafile}" TO COPY;
3243
RECOVER DATAFILE "${datafilecopy}";
3344
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
3457
DELETE DATAFILECOPY "${datafile}";
3558
EOF
3659

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+
3768
done

0 commit comments

Comments
 (0)