<commit_before>#!/bin/bash -xe

##################################################################################
function usage(){
  echo "usage: $(basename $0) /path/to/jenkins_home archive.tar.gz"
}
##################################################################################

readonly JENKINS_HOME=$1
readonly DIST_FILE=$2
readonly CUR_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
readonly TMP_DIR="$CUR_DIR/tmp"
readonly ARC_NAME="jenkins-backup"
readonly ARC_DIR="$TMP_DIR/$ARC_NAME"
readonly TMP_TAR_NAME="archive.tar.gz"

if [ -z "$JENKINS_HOME" -o -z "$DIST_FILE" ] ; then
  usage >&2
  exit 1
fi

if [[ -f "$TMP_DIR/$TMP_TAR_NAME" ]]; then
    rm $TMP_DIR/$TMP_TAR_NAME
fi
rm -rf $ARC_DIR
mkdir -p $ARC_DIR/{plugins,jobs,users}

cp $JENKINS_HOME/*.xml $ARC_DIR
cp $JENKINS_HOME/plugins/*.jpi $ARC_DIR/plugins
cp -R $JENKINS_HOME/users/* $ARC_DIR/users

cd $JENKINS_HOME/jobs/
ls -1 | while read job_name
do
  mkdir -p $ARC_DIR/jobs/"$job_name"/
  cp $JENKINS_HOME/jobs/"$job_name"/*.xml $ARC_DIR/jobs/"$job_name"/
done

cd $TMP_DIR
tar czvf $TMP_TAR_NAME $ARC_NAME/*
cp $TMP_DIR/$TMP_TAR_NAME $DIST_FILE<commit_msg>Escape bug fix and few tweaks<commit_after>#!/bin/bash -xe

##################################################################################
function usage(){
  echo "usage: $(basename $0) /path/to/jenkins_home archive.tar.gz"
}
##################################################################################

readonly JENKINS_HOME=$1
readonly DIST_FILE=$2
readonly CUR_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
readonly TMP_DIR="$CUR_DIR/tmp"
readonly ARC_NAME="jenkins-backup"
readonly ARC_DIR="$TMP_DIR/$ARC_NAME"
readonly TMP_TAR_NAME="archive.tar.gz"

if [ -z "$JENKINS_HOME" -o -z "$DIST_FILE" ] ; then
  usage >&2
  exit 1
fi

if [[ -f "$TMP_DIR/$TMP_TAR_NAME" ]]; then
    rm "$TMP_DIR/$TMP_TAR_NAME"
fi
rm -rf "$ARC_DIR"
mkdir -p "$ARC_DIR/"{plugins,jobs,users}

cp "$JENKINS_HOME/"*.xml "$ARC_DIR"
cp "$JENKINS_HOME/plugins/"*.jpi "$ARC_DIR/plugins"
cp -R "$JENKINS_HOME/users/"* "$ARC_DIR/users"

cd "$JENKINS_HOME/jobs/"
ls -1 | while read job_name
do
  echo $job_name
  mkdir -p "$ARC_DIR/jobs/$job_name/"
  cp "$JENKINS_HOME/jobs/$job_name/"*.xml "$ARC_DIR/jobs/$job_name/"
done

cd "$CUR_DIR"
tar -czvf "$TMP_DIR/$TMP_TAR_NAME" "$TMP_DIR/$ARC_NAME/"*
cp "$TMP_DIR/$TMP_TAR_NAME" "$DIST_FILE"

exit 0
{'fraction_non_alphanumeric': 0.28717077315208156, 'fraction_numerical': 0.006372132540356839, 'mean_word_length': 5.84593023255814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1308149', 'n_tokens_mistral': 961, 'n_tokens_neox': 912, 'n_words': 180}