Skip to content

Commit

Permalink
clean up tmp directories and files after successful tar creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Jagdmann committed Jul 21, 2015
1 parent 1c0508e commit fb1f419
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions jenkins-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ if [ -z "$JENKINS_HOME" -o -z "$DEST_FILE" ] ; then
exit 1
fi

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

cp "$JENKINS_HOME/"*.xml "$ARC_DIR"

cp "$JENKINS_HOME/plugins/"*.[hj]pi "$ARC_DIR/plugins"
hpi_pinned_count=$(find $JENKINS_HOME/plugins/ -name *.hpi.pinned | wc -l)
jpi_pinned_count=$(find $JENKINS_HOME/plugins/ -name *.jpi.pinned | wc -l)
Expand All @@ -49,8 +47,9 @@ if [ -d "$JENKINS_HOME/jobs/" ] ; then
done
fi

cd "$TMP_DIR"
tar -czvf "$TMP_DIR/$TMP_TAR_NAME" "$ARC_NAME/"*

cp "$TMP_DIR/$TMP_TAR_NAME" "$DEST_FILE"
mv -f "$TMP_DIR/$TMP_TAR_NAME" "$DEST_FILE"
rm -rf "$ARC_DIR"

exit 0

0 comments on commit fb1f419

Please sign in to comment.