Small and Medium database RMAN CATALOG Backup recovery Scheme (ii)

Source: Internet
Author: User
Tags log log

Small and medium-sized databases are characterized by less database concurrency, smaller database capacity, limited version functionality, and more than one instance of N. However, the loss level of the database can also be lost in 0 cases. Enterprises do not want to spend too much money and to ensure the reliable stability of the database, but the bitter evil I do these db. Next to an article, the small and medium database RMAN CATALOG Backup recovery Scenario (i), we continue to give a small and medium-sized database based on the recovery of the script and its deployment.

1. Rman Restore shell Script

[Python]View PlainCopyprint?
  1. --The following shell script is used to automate the database restore, and the database is closed after the restore succeeds. Because we have no exception in the PROD database, we do not need Bak's standby library open
  2. The--shell script does a restore when the global script in catalog is called Global_restore
  3. --At the very end of the script, we output the DB Restore success status to the log file Db_restore_rman.log, and the benefit is that we can set the restore state of multiple db to make it easier to see
  4. $ more db_restore_rman_catalog.sh
  5. ##====================================================================
  6. # # File Name:db_restore_rman_catalog.sh
  7. # # Usage:db_restore_rman_catalog.sh < $ORACLE _sid>
  8. # Desc:
  9. # # The script uses to restore database with level 0 backupset.
  10. # # Author:robinson
  11. # # blog:http://blog.csdn.net/robinson_0612
  12. ##====================================================================
  13. #!/bin/bash
  14. # --------------------
  15. # Define Variable
  16. # --------------------
  17. If [-f ~/.bash_profile]; Then
  18. . ~/.bash_profile
  19. Fi
  20. # --------------------------
  21. # Check SID
  22. # --------------------------
  23. If [-Z ' ${1} '];then
  24. Echo "Usage:"
  25. echo "' basename ' Oracle_sid"
  26. Exit 1
  27. Fi
  28. oracle_sid=${1}; Export Oracle_sid
  29. Log_dir=/u02/database/${oracle_sid}/backup; Export Rman_dir
  30. timestamp= ' Date +%y%m%d%h%m ' export TIMESTAMP
  31. Rman_log=${log_dir}/${oracle_sid}_restore_${timestamp}.log; Export Rman_log
  32. Ssh_log=${log_dir}/${oracle_sid}_restore_full_${timestamp}.log; Export Ssh_log
  33. retention=5
  34. echo "----------------------------------------------------------------" >>${ssh_log}
  35. echo "Start Rman to backup at ' date '." >>${ssh_log}
  36. echo "----------------------------------------------------------------" >>${ssh_log}
  37. $ORACLE _home/bin/rman target/catalog rman_user/[email protected] Log=${rman_log} <<eof
  38. Startup Nomount;
  39. Run{execute Global script Global_restore;}
  40. Exit
  41. Eof
  42. Rv=$?
  43. Cat ${rman_log}>>${ssh_log}
  44. echo "" >>${ssh_log}
  45. echo "----------------------------------------------------------------" >>${ssh_log}
  46. echo "Msg1:rman restore end at ' date '." >>${ssh_log}
  47. echo "----------------------------------------------------------------" >>${ssh_log}
  48. If [$RV-ne "0"]; Then
  49. echo "----------------------------------------------------------------" >>${ssh_log}
  50. echo "Msg2:rman restore error at ' date '." >>${ssh_log}
  51. echo "----------------------------------------------------------------" >>${ssh_log}
  52. rman_stat=' FAILED '
  53. Mail-s "Failed RMAN restore for $ORACLE _sid on ' hostname '." [Email protected] 12306.com <${ssh_log}
  54. Else
  55. echo "----------------------------------------------------------------" >>${ssh_log}
  56. echo "Msg2:no error found for RMAN restore at ' date '." >>${ssh_log}
  57. echo "----------------------------------------------------------------" >>${ssh_log}
  58. rman_stat=' succeed '
  59. RM-RF ${rman_log} 2>/dev/null
  60. Fi
  61. echo "' Date ' +%f%x '--$ $RMAN _stat" >>/u01/comm_scripts/db_restore_rman.log
  62. Exit

2. Detect the Restore state shell script

[Python]View PlainCopyprint?
  1. --We used a shell script to detect the success of the final restore state on the day of multiple db and output all current records to the Ck_restore.log log
  2. --The end of the script sends a message that lists all the states after the restore, and is a summary report for multiple DB restore.
  3. $ more ck_restore.sh
  4. ##====================================================================
  5. # # File Name:ck_restore.sh
  6. # # Usage:ck_restore.sh
  7. # Desc:
  8. # # The script uses to check RMAN restore Log for current day
  9. # # and send mail to DBA
  10. # # Author:robinson
  11. # # blog:http://blog.csdn.net/robinson_0612
  12. ##====================================================================
  13. #!/bin/bash
  14. If [-f ~/.bash_profile];
  15. Then
  16. . ~/.bash_profile
  17. Fi
  18. Rev_dir=/u01/comm_scripts
  19. dt= ' Date ' +%f '
  20. Cat/dev/null >${rev_dir}/ck_restore.log
  21. Cat ${rev_dir}/db_restore_rman.log | grep "${dt}" >>${rev_dir}/ck_restore.log
  22. Total= ' Cat ${rev_dir}/ck_restore.log |wc-l '
  23. Suc= ' grep succeed ${rev_dir}/ck_restore.log |wc-l '
  24. Fail= ' grep FAILED ${rev_dir}/ck_restore.log |wc-l '
  25. echo "" >>ck_restore.log
  26. ECHO-E "The total DB of current recovery are $total in ' hostname ' \ n" >>${rev_dir}/ck_restore.log
  27. ECHO-E "The number of Succee is: ${suc} \ n" >>${rev_dir}/ck_restore.log
  28. ECHO-E "The number of fail is: ${fail} \ n" >>${rev_dir}/ck_restore.log
  29. Mail-s "RMAN Restore Summary for ' hostname ' at ' date + '%a%b%d%Y '" [email protected]12306.com <${rev_dir}/c K_restore.log

3. Deploy the Restore shell script to crontab

[Python]View PlainCopyprint?
  1. --first encapsulate multiple db requiring automatic restore into a single file, as follows:
  2. --finally call ck_restore.sh footstep to detect all DB restore status and send Rman summary report message
  3. $ more full_resotre_by_rman.sh
  4. #!/bin/bash
  5. /u01/comm_scripts/db_restore_rman_catalog.sh BC1200
  6. /u01/comm_scripts/db_restore_rman_catalog.sh AF2630
  7. /u01/comm_scripts/ck_restore.sh
  8. --Deploy to Crontab
  9. -note, whether it is a backup or a recovery script, we are deployed through Bak server crontab to relieve prod pressure
  10. #Rman RESTORE Database
  11. 0 3 * * 1-6/u01/comm_scripts/full_resotre_by_rman.sh
Ext.: http://blog.csdn.net/leshami/article/details/9850665

Small and Medium database RMAN CATALOG Backup recovery Scheme (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.