BackupPC-users

Re: [BackupPC-users] DumpPreUserCmd to send an email before and after backup

2009-02-02 17:45:18
Subject: Re: [BackupPC-users] DumpPreUserCmd to send an email before and after backup
From: Nick Smith <nick.smith79 AT gmail DOT com>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Mon, 2 Feb 2009 17:42:37 -0500
Wow, that looks pretty impressive! I would like to try something like
that out at my site.
I had a couple questions.

Where are the variables defined? aka $user $host $3 etc?
Are they internal backuppc variables already defined or do i need to
do that somewhere?

thanks for the help, and thanks for posting this.

On Thu, Jan 29, 2009 at 5:33 AM, Les Stott <les AT cyberpro.com DOT au> wrote:
> Madcha wrote:
>> Thanks,
>>
>> But how write this command, for send an email to $host? or $user?
>>
>>
> Here is one way to do it, maybe not the most elegant but it works. Use
> it as a guide and improve on it. I set this up ages ago for a client,
> never tweaked it since then.
>
> These will send a note before to say its starting, and then send a note
> after if it completes, whether successful or not. It will also log to
> the hosts backuppc log file. If there is an error it will log that also.
>
> You need to create 4 files. the sample scripts below assume you put them
> in /usr/local/bin
>
> startbkpemail.txt      -> body text for email before
> startbkpemail.sh       -> script to send the email before
> endbkpemail.txt       -> body text for email after
> endbkpemail.sh         -> script to send email after
>
> Modify the variables at the top of the scripts to suit your setup.
>
> Call them in BackupPC like so....
> $Conf{DumpPreUserCmd}    = '/usr/local/bin/startbkpemail.sh $user
> $xferOK $host $type $cmdType';
> $Conf{DumpPostUserCmd}    = '/usr/local/bin/endbkpemail.sh $user $xferOK
> $host $type $cmdType';
>
> they should contain something like:
>
> startbkpemail.txt
> ---------------------------------------------------------
> THIS IS AN AUTOMATED SYSTEM MESSAGE!!
> PLEASE DO NOT REPLY!!
>
> Your Computer is being backed up by the
> Automated System Backup Server.
>
> During this time you may experience some slowness on
> the network. This is usually only for a short period.
>
> You will receive a confirmation E-mail when the
> Backup Completes.
> ---------------------------------------------------------
>
> startbkpemail.sh
> ---------------------------------------------------------
> #!/bin/sh
> #
> #$Conf{DumpPreUserCmd}    = '/usr/local/bin/startbkpemail.sh $user
> $xferOK $host $type $cmdType';
> #$Conf{DumpPostUserCmd}    = '/usr/local/bin/endbkpemail.sh $user
> $xferOK $host $type $cmdType';
>
> varDate=`date '+%F %T'`
> DOMAIN=yourdomain.com.au
> BACKUPPCPATH=/path/to/data/directory
> BACKUPPCLOG=$BACKUPPCPATH/log/LOG
> NOTIFY=${1}@${DOMAIN}
>
> /bin/mail -s"A Backup of $3 has started..." ${NOTIFY} <
> /usr/local/bin/startbkpemail.txt
> /bin/echo "$varDate Backup Started E-mail sent to:(' $1' )" >>$BACKUPPCLOG
> ---------------------------------------------------------
>
> endbkpemail.txt
> ---------------------------------------------------------
> THIS IS AN AUTOMATED SYSTEM MESSAGE!!
> PLEASE DO NOT REPLY!!
>
> Your Computer has been backed up by the
> Automated System Backup Server.
> ---------------------------------------------------------
>
> endbkpemail.sh
> ---------------------------------------------------------
> #!/bin/sh
> #
> #$Conf{DumpPreUserCmd}    = '/usr/local/bin/startbkpemail.sh $user
> $xferOK $host $type $cmdType';
> #$Conf{DumpPostUserCmd}    = '/usr/local/bin/endbkpemail.sh $user
> $xferOK $host $type $cmdType';
>
> varDate=`date '+%F %T'`
> DOMAIN=yourdomain.com.au
> BACKUPPCPATH=/path/to/data/directory
> BACKUPPCLOG=$BACKUPPCPATH/log/LOG
> NOTIFY=${1}@${DOMAIN}
>
> ### If $2 is a 1, backup completed.
>
> if [ $2 = 1 ]
> then
>   /bin/mail -s"Backup of $3 has Completed Successfully." ${NOTIFY} <
> /usr/local/bin/endbkpemail.txt
>   /bin/echo "$varDate Backup Completed E-mail sent to:(' $1' )"
>  >>$BACKUPPCLOG
> else
>   /bin/mail -s"Backup of $3 has Failed. Contact your System Admin."
> ${NOTIFY} < /usr/local/bin/endbkpemail.txt
>   /bin/echo $varDate 'Exit code:(' $2 ') Asset Tag:(' $3')  E-Mail:('
> $1' )' >>$BACKUPPCLOG
> fi
> ---------------------------------------------------------
>
> That should give you a good starting point.
>
> Regards,
>
> Les
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> BackupPC-users mailing list
> BackupPC-users AT lists.sourceforge DOT net
> List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
> Wiki:    http://backuppc.wiki.sourceforge.net
> Project: http://backuppc.sourceforge.net/
>

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

<Prev in Thread] Current Thread [Next in Thread>