-
-
Save rudolfovich/8e3f5363b590e303fa7fcf0bc49225a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# source: https://medium.com/@_oleksii_/how-to-backup-and-restore-jenkins-complete-guide-62fc2f99b457 | |
# Jenkins Configuraitons Directory | |
cd $JENKINS_HOME | |
git fetch | |
git merge --commit | |
# Add general configurations, job configurations, and user content | |
git add -- *.xml | |
git add -- userContent/* | |
find jobs/ -name config.xml -exec git add -- {} \; | |
find jobs/ -name state.xml -exec git add -- {} \; | |
find jobs/ -name name-utf8.txt -exec git add -- {} \; | |
find jobs/ -name svnexternals.txt -exec git add -- {} \; | |
find jobs/ -name scm-revision-hash.xml -exec git add -- {} \; | |
find jobs/ -name scm-last-seen-revision-hash.xml -exec git add -- {} \; | |
find plugins/ -iname '*.jpi' -exec git lfs track {} \; | |
# find plugins/ -iname '*.jpi' -exec git add --ignore-errors -- {} \; | |
git add -- plugins/ | |
# only add user configurations if they exist | |
if [ -d users ]; then | |
user_configs=`ls users/*/config.xml` | |
if [ -n "$user_configs" ]; then | |
git add $user_configs | |
fi | |
git add "users/users.xml" | |
fi | |
# mark as deleted anything that's been, well, deleted | |
to_remove=`git status | grep "deleted" | awk '{print $3}'` | |
if [ -n "$to_remove" ]; then | |
git rm --ignore-unmatch $to_remove | |
fi | |
git commit --all -m "BugId:none Jenkins Automated Backup: ${BUILD_TAG}" | |
git push -q -u origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment