<commit_before>#!/bin/bash

# rdiff-backup job script for $JOB managed by Chef. Changes will be overwritten.

# This script is normally run by cron, but can be run manually to start the job if it is not already running.

FILE=`basename $0`
DIR=`dirname $0`
PIDFILE="$DIR/.$FILE.lock"
JOB="${FILE%.sh}"
LOGPATH='/var/log/rdiff-backup'
INSTANCES=`pgrep -fu <%= @suser %> $FILE | wc -l`

# Prepends date to every line of stdin, then writes to both stdout and the log file.
function log() {
  sed "s/^/[`date +'%Y-%m-%d %H:%M:%S'`] /" | tee >(/usr/sbin/cronolog "${LOGPATH}/${JOB}/%Y-%m.log")
}

# Prepends date to every line of stdin, then writes to stdout and both the individual and general log files.
function logboth() {
  sed "s/^/[`date +'%Y-%m-%d %H:%M:%S'`] /" | tee >(/usr/sbin/cronolog "${LOGPATH}/${JOB}/%Y-%m.log") >(/usr/sbin/cronolog "${LOGPATH}/general/%Y-%m-%d.log" -S "${LOGPATH}/current.log" -P "${LOGPATH}/previous.log")
}

# If we're root instead of the rdiff-backup server user, rerun the script as it.
if [ `whoami` = 'root' ]; then
  su <%= @suser %> -c $0
else

  # Only run if this script isn't already running
  if [ $INSTANCES -lt 3 ]; then
    echo $$ > $PIDFILE

    echo '----------------------------------------' | log

    echo "Backup starting for '$JOB'..." | logboth
    rdiff-backup <%= @args %> --force --create-full-path --exclude-device-files \
      --exclude-fifos --exclude-sockets --exclude-other-filesystems \
      --exclude-globbing-filelist "${DIR}/../exclude/<%= @fqdn %>_<%= @src.gsub('/', '-') %>" \
      --remote-schema \<commit_msg>remove -P option for cronolog in job script since it doesn't work in this situation<commit_after>#!/bin/bash

# rdiff-backup job script for $JOB managed by Chef. Changes will be overwritten.

# This script is normally run by cron, but can be run manually to start the job if it is not already running.

FILE=`basename $0`
DIR=`dirname $0`
PIDFILE="$DIR/.$FILE.lock"
JOB="${FILE%.sh}"
LOGPATH='/var/log/rdiff-backup'
INSTANCES=`pgrep -fu <%= @suser %> $FILE | wc -l`

# Prepends date to every line of stdin, then writes to both stdout and the log file.
function log() {
  sed "s/^/[`date +'%Y-%m-%d %H:%M:%S'`] /" | tee >(/usr/sbin/cronolog "${LOGPATH}/${JOB}/%Y-%m.log")
}

# Prepends date to every line of stdin, then writes to stdout and both the individual and general log files.
function logboth() {
  sed "s/^/[`date +'%Y-%m-%d %H:%M:%S'`] /" | tee >(/usr/sbin/cronolog "${LOGPATH}/${JOB}/%Y-%m.log") >(/usr/sbin/cronolog "${LOGPATH}/general/%Y-%m-%d.log" -S "${LOGPATH}/current.log")
}

# If we're root instead of the rdiff-backup server user, rerun the script as it.
if [ `whoami` = 'root' ]; then
  su <%= @suser %> -c $0
else

  # Only run if this script isn't already running
  if [ $INSTANCES -lt 3 ]; then
    echo $$ > $PIDFILE

    echo '----------------------------------------' | log

    echo "Backup starting for '$JOB'..." | logboth
    rdiff-backup <%= @args %> --force --create-full-path --exclude-device-files \
      --exclude-fifos --exclude-sockets --exclude-other-filesystems \
      --exclude-globbing-filelist "${DIR}/../exclude/<%= @fqdn %>_<%= @src.gsub('/', '-') %>" \
      --remote-schema \
{'fraction_non_alphanumeric': 0.21653666146645867, 'fraction_numerical': 0.0024960998439937598, 'mean_word_length': 2.9629171817058095, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '1050300', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1123, 'n_words': 344}