Python sends the RMAN backup log script

Source: Internet
Author: User

 

The logs backed up by RMAN are put in a file. The backup script in nocatalg was sent using Linux Sendmail. However, this affects the system startup time. It is still sent using python. After the backup, call the script. Send RMAN logs to the mailbox. Check the email in the morning to check whether the backup is successful. Otherwise, it would be a little tiring to connect one server.

 

Shell script for incremental RMAN backup under nocatalog

Http://blog.csdn.net/tianlesoftware/archive/2011/01/26/6164931.aspx

 

The RMAN backup script of nocatalog will generate a log file under the same directory as the backup script. The following Python script sends the log file to the mailbox.

 

 

The Python script is simple as follows:

 

$ Cat sendrmanlog. py

#! /Usr/bin/Python

# Coding = GBK

# Created by tianlesoftware

#2011/2/24

Import OS

Import sys

Import smtplib

 

From_user = 'tianlesoftware @ vip.qq.com'

Smtp_server = '192. 168.1.100'

Email_user = 'tianlesoft'

Email_passwd = 'pwd'

To_users = ['tianlesoftware @ vip.qq.com ', 'tianlesoftware @ vip.qq.com']

 

Def mysendmail (fromaddr, toaddrs, subject, body ):

Server = smtplib. SMTP (smtp_server)

Server. login (email_user, email_passwd)

For toaddr in toaddrs:

MSG = 'from: % S/nto: % S/nsubject: % s/n % S/N' % (fromaddr, toaddr, subject, body)

Server. Sendmail (fromaddr, toaddr, MSG)

Server. Quit ()

 

Def load (fname = '/u01/backup/scripts/rman_backup.sh.out '):

Fp = open (fname)

Log = FP. Read ()

FP. Close ()

Return log

 

Body = load ()

Print body

Subject = '1970. 168.88.209 RMAN backup Log'

Mysendmail (from_user, to_users, subject, body)

 

 

Add the script to crontab:

$ Crontab-l

00 9 ***/u01/backup/scripts/sendrmanlog. py>/u01/backup/scripts/sendrmanlog. log 2> & 1

 

 

 

------------------------------------------------------------------------------

Blog: http://blog.csdn.net/tianlesoftware

Online Resources: http://tianlesoftware.download.csdn.net

Video: http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx

Dba1 group: 62697716 (full); dba2 group: 62697977 (full)

Dba3 group: 62697850 super DBA group: 63306533;

Chat group: 40132017

-- Add the group to describe the relationship between Oracle tablespace and data files in the remarks section. Otherwise, the application is rejected.

Related Article

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.