#!/bin/sh
# Retrospect Client retroeventhandler script
# 
# Contact Information 
# 
# Retrospect, Inc.
# Pleasanton, CA 
# http://www.retrospect.com
# 
# (C) 2014 Retrospect, Inc. Portions (C) 1989-2011 EMC Corporation. All rights reserved. 
#
#
# How to use this script
# 
# Any executable with pathname /etc/retroeventhandler will be run 
# at the beginning and end of each source in a scripted backup. 
# The executable is passed one of the following parameter arrays:
#
#  StartSource, Script name(string), Source path(string),
#  Source name(string), Client name(string), Err file(empty)
#
#  EndSource, Script name(string), Source path(string),
#  Source name(string), Client name(string), KB stored(int),
#  Files stored(int), Duration in seconds(int), Source
#  start(date string), Source end(date string), 
#  Script start(date string), Backup set(string), 
#  Backup type(string), Source parent(string),
#  Errors(int), Fatal errors(int), Result(string)
#
# If a non-zero exit code is encountered for an execution trig-
# gered by the StartSource event, that backup source will 
# be skipped.
#
# Notes
# 1. The Source path is non-intuitive for mount points; it shows 
#    the Retrospect object path rather than the Linux or Unix path. For 
#    example, on client Bongo Fury  with an external drive mounted 
#    to /mnt/ext, the source path is "Backup Clients/Bongo Fury/ext", 
#    while the source name is "/mnt/ext".
#
# 2. Parameters 2 through 17 are passed double-quoted, so you
#    have to include the double quotes in your string for exact
#    pattern matching in tests (e.g. $X = [ "\"ScriptName\"" ])

# This sample script appends a timestamp and the arguments it 
# receives to a log file.
LOGFILE=/root/events.log
date >>$LOGFILE
for X in "$@"; do
    echo $X >>$LOGFILE
done

# This sample script prevents a script named Invasive from
# backing up the /mnt/ext mountpoint.
if [ $2 = "\"Invasive\"" ] && [ $4 = "\"/mnt/ext\"" ]; then
	exit 1
fi
