Tomasz Klimaszewski wrote:
> Hello
> I installed backuppc 3.0.0 and work mostly with CGI interface.
> I wounder if it possible and if yes I wounder how to configurate email
> notifiaction about all yesterday backups.
> My aim is to get:
> one mail with info of each hosts and files it backuped up.
> And one more thing mail with info about hosts didn't backup up any new
> files.
>
> Thx in advance
>
> -- 
> somebody known as:
> Tomasz Klimaszewski
> klimae[at]gmail[dot]com

Hi Tomasz;

There was a thread on this earlier that got me going and here is a
summary from the archives to give you ideas:
http://search.gmane.org/search.php?group=gmane.comp.sysutils.backup.backuppc.general&query=email+summary+daily

I was looking for the same thing to bug delinquent users and quickly
modified a simple contribution script by Jean-Michel Beuken.
(
http://thread.gmane.org/gmane.comp.sysutils.backup.backuppc.general/9055/focus=10040
)

It is executed via the hosts post dump option and uses built in
variables available to this post backup command.
$Conf{DumpPostUserCmd} = '/pathtobackuppc/bin/*BackupPC_notify $user
$xferOK $host $type $shares*';

The scripts runs every time a backup executes on the target host. You
could could make it a global config directive to affect all subscribed
hosts but this could get annoying. No news about backups is good news
for me.

To satisfy your "mail with info about hosts didn't backup up any new
files" requirement you could extend to do a 'tail
/pathtodatadir/pc/$host/LOG.~date~'  into the email to get the raw lines
and send that out based on some policy you decide. perl or (ummm) awk
can be your friends here to search the log file.

Have fun... The possibilities are endless when it comes to email and
when you already have the data on hand.

    Allen...

-- 
/////////////////////////////////////////
Break away from the Gates of Windows...
        Support OpenSource communities.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

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

#!/usr/bin/perl
#################
# (extract from the BackupPC Help page)
#       The following variable substitutions are made at run time for
#       $Conf{DumpPreUserCmd}, $Conf{DumpPostUserCmd}, $Conf{DumpPreShareCmd} 
and $Conf{DumpPostShareCmd}:
#
#           $type         type of dump (incr or full)
#           $xferOK       1 if the dump succeeded, 0 if it didn't
#           $client       client name being backed up
#           $host         host name (could be different from client name if
#                                   $Conf{ClientNameAlias} is set)
#           $hostIP       IP address of host
#           $user         user name from the hosts file
#           $moreUsers    list of additional users from the hosts file
#           $share        the first share name (or current share for
#                           $Conf{DumpPreShareCmd} and $Conf{DumpPostShareCmd})
#           $shares       list of all the share names
#           $XferMethod   value of $Conf{XferMethod} (eg: tar, rsync, smb)
#           $sshPath      value of $Conf{SshPath},
#           $cmdType      set to DumpPreUserCmd or DumpPostUserCmd
$version = "1.0.2";

#
# Inbound arguments
$user = $ARGV[0];
$xferOK = $ARGV[1];
$host = $ARGV[2];
$type = $ARGV[3];
$shares = $ARGV[4];

#Mail settings
$mailprog = '/usr/lib/sendmail';
$recipient = $user;


## Start Code
$msg = <<END_MSG_BODY;
        BACKUP REPORT for host: $host
        
        Summary:
        ========        
END_MSG_BODY

if ( $xferOK) {
        $msg .= <<END_MSG_OK;
        The ($type) backup completed with status: SUCCESS 
        The following shares were backed up:
        $shares
        
        
        
        Support Info:
        =============
        Check status or initiate a backup anytime here:
        <http://servername/cgi-bin/BackupPC/BackupPC_Admin?host=$host>
        
        
        Contact support: mailto:[EMAIL PROTECTED]
        
        
        Thank you for your attention and have a nice day!
END_MSG_OK

        $subject = "BackupPC: status for $host : SUCCESS";
        &sendmail($msg);

} else {
        $msg .= <<END_MSG_FAIL;
        The ($type) backup completed with status: FAILURE 
        An attempt was made to backup the following shares:
        $shares
        
        
        Support Info:
        =============
        You can choose to ignore this messsage if you know the reason for the 
failure. (Like PC being turned off)
        The normal backup cycle is still in effect.
        
        You can manually re-initiate a backup from here and selecting Start 
$type Backup:
        <http://servername/cgi-bin/BackupPC/BackupPC_Admin?host=$host>
        
        You can contact support otherwise to investigate further.
        Contact: mailto:[EMAIL PROTECTED]
        
        
        Thank you for your attention and have a nice day!
END_MSG_FAIL

        $subject = "BackupPC: status for $host : FAILURE !";
        &sendmail($msg);
}

sub sendmail {
     my($msg) =  @ _;
    open(MAIL, "|$mailprog -t") && do {
         print MAIL "To: $recipient\n";
         print MAIL "From: BU_Admin\n";
#        print MAIL "Cc:\n";
#        print MAIL "Bcc:\n";
         print MAIL "Subject: $subject\n\n";
         print MAIL "$msg\n";

         close (MAIL);
    };
}


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
BackupPC-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/backuppc-users
http://backuppc.sourceforge.net/

Reply via email to