1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/bash MAILTO="<%= @mailto %>" EXCL_FROM=`mktemp` FILES_FROM=`mktemp` TMP_STDERR=`mktemp` on_exit() { if [ -s "$TMP_STDERR" ]; then cat "$TMP_STDERR" | mail -Ssendwait -s "save_distant rsync error" "$MAILTO" fi rm -f $TMP_STDERR $EXCL_FROM $FILES_FROM } trap "on_exit" EXIT exec 2> "$TMP_STDERR" exec < /dev/null set -e