<commit_before>#!/bin/bash
#
# Do rsync backups to local ZFS storage (with snapshots)
# 
# This and all related files in this directory are in the public domain.
#
# Author: <NAME>
#
# Requires:
#   * rsync
#   * ZFS
#   * zfs-auto-snapshot
#   * zip (to compress logs for mail reports)
#   * mutt (to send mail with attachment)
#
MAIL_RECIPS=""

MYDIR=`dirname $0`
cd $MYDIR

TIMESTAMP=`date +%Y%m%d-%H%M%S`

LOGDIR=/var/log/rs-backups
if [ ! -d ${LOGDIR} -o ! -d ${LOGDIR}/jobs ]; then
  echo "${LOGDIR}/jobs does not exist. Create it first."
  exit 1
fi

ERRORS=0
for job in `ls jobs/*.conf`; do
  ${MYDIR}/run_job $job | tee -a ${LOGDIR}/${job}-${TIMESTAMP}.log
  rv=$?
  if [ $rv -gt 0 ]; then
    ERRORS=1
  fi
done

#
# send mail
#
if [ $ERRORS -gt 0 ]; then
  mail_subject="RS-BACKUP: ERRORS (${TIMESTAMP})"
else
  mail_subject="RS-BACKUP: OK (${TIMESTAMP})"
fi

# create zip attachment with the logs
zip ${LOGDIR}/${TIMESTAMP}-logs.zip ${LOGDIR}/jobs/*-${TIMESTAMP}.log && \
  rm -f ${LOGDIR}/jobs/*-{TIMESTAMP}.log

if [ ! -z $MAIL_RECIPS ]; then
  mutt -s "$mail_subject" "$MAIL_RECIPS" -a ${LOGDIR}/*-${TIMESTAMP}-logs.zip <<< "logs attached"
fi
  <commit_msg>and junk the logfile paths in zip. Who wants to click 4 times to get to the juicy part?<commit_after>#!/bin/bash
#
# Do rsync backups to local ZFS storage (with snapshots)
# 
# This and all related files in this directory are in the public domain.
#
# Author: <NAME>
#
# Requires:
#   * rsync
#   * ZFS
#   * zfs-auto-snapshot
#   * zip (to compress logs for mail reports)
#   * mutt (to send mail with attachment)
#
MAIL_RECIPS=""

MYDIR=`dirname $0`
cd $MYDIR

TIMESTAMP=`date +%Y%m%d-%H%M%S`

LOGDIR=/var/log/rs-backups
if [ ! -d ${LOGDIR} -o ! -d ${LOGDIR}/jobs ]; then
  echo "${LOGDIR}/jobs does not exist. Create it first."
  exit 1
fi

ERRORS=0
for job in `ls jobs/*.conf`; do
  ${MYDIR}/run_job $job | tee -a ${LOGDIR}/${job}-${TIMESTAMP}.log
  rv=$?
  if [ $rv -gt 0 ]; then
    ERRORS=1
  fi
done

#
# send mail
#
if [ $ERRORS -gt 0 ]; then
  mail_subject="RS-BACKUP: ERRORS (${TIMESTAMP})"
else
  mail_subject="RS-BACKUP: OK (${TIMESTAMP})"
fi

# create zip attachment with the logs
zip -j ${LOGDIR}/${TIMESTAMP}-logs.zip ${LOGDIR}/jobs/*-${TIMESTAMP}.log && \
  rm -f ${LOGDIR}/jobs/*-{TIMESTAMP}.log

if [ ! -z $MAIL_RECIPS ]; then
  mutt -s "$mail_subject" "$MAIL_RECIPS" -a ${LOGDIR}/*-${TIMESTAMP}-logs.zip <<< "logs attached"
fi
  
{'fraction_non_alphanumeric': 0.17802560925237504, 'fraction_numerical': 0.0053696819496076, 'mean_word_length': 3.4851851851851854, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4459024', 'n_tokens_mistral': 982, 'n_tokens_neox': 960, 'n_words': 277}