Skip to content

Instantly share code, notes, and snippets.

@dmotylev
Created December 18, 2014 16:36
Show Gist options
  • Save dmotylev/4f9c29f9cf31401511b9 to your computer and use it in GitHub Desktop.
Save dmotylev/4f9c29f9cf31401511b9 to your computer and use it in GitHub Desktop.
Builds a jenkins-config.tar.gz in current directory. The archive includes full JENKINS_HOME but builds/ and workspaces/.
#!/bin/sh
readonly jenkins_data=/var/lib/jenkins
readonly jenkins_data_escaped=$(echo $jenkins_data | sed -E 's/\//\\\//g')
readonly filelist=$(mktemp)
find $jenkins_data |
sed -E "
s/^$jenkins_data_escaped\///;
/^${jenkins_data_escaped}$/d;
/^jobs\/.*?\/(builds|workspace|last.*)/d;
/^(\.java|log|updates).*/d;
/^.*\.bak$/d
/jenkins-config\.tar\.gz/d
" > $filelist
tar --create --gzip --file jenkins-config.tar.gz \
--directory=$jenkins_data/ --no-recursion --files-from=$filelist
rm $filelist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment