White Papers

Best Practices for Oracle 11g Backup and Recovery using RMAN and Dell EqualLogic Snapshots
37
Appendix B Automation of snapshot-based backup
In Example 2 we provide the source for the expect script used to automate parts of the user managed
backup method presented in Section 5. This expect script performs three tasks:
1. Place the database in hot backup mode
2. Create the snapshot collection on the EqualLogic storage array
3. Take the database out of hot backup mode
Example 2 – User managed backup automation script
#!/usr/bin/expect -f
set VOL_COL [ lindex $argv 1 ]
set SNAP_NAME [ lindex $argv 2 ]
# Check for at least 1 arguments.
#
if { [ llength $argv ] < 3 } {
puts "Usage: $argv0 \"Array IP Address\" \"Volume Collection\" \"Snapshot
Name\" "
exit
}
set timeout 30
# Put the database in hot backup mode"
spawn sqlplus / as sysdba;
expect "SQL>"
send "alter database begin backup;\r"
expect "SQL>"
send "exit\r"
expect "*$"
spawn telnet [ lindex $argv 0 ]
set timeout 30
expect "login:"
send "grpadmin\r"
expect "Password:"
sleep 1
send "eql\r"
expect {
timeout {
return 1
}
"Login incorrect" {
return 1
}
"> " {
sleep 1
send "snapcol create $VOL_COL $SNAP_NAME description test\r"
expect "> " {
send "logout\r"