Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Copies certain kinds of known files and directories from a given Jenkins master directory
- # into a git repo, removing any old ones, adds 'em, commits 'em, pushes 'em.
- set -ex
- if [ $# -ne 3 ]; then
- echo usage: $0 jenkins_home hg_repos_url hg_repos_name
- exit 1
- fi
- JENKINS_HOME=$1
- HG_REMOTE_URL=$2
- HG_REPOS_NAME=$3
- rm -rf ${HG_REPOS_NAME}
- hg clone ${HG_REMOTE_URL}
- rsync -ahv --delete \
- --exclude="jobConfigHistory" \
- --exclude="config-history" \
- --exclude="war" \
- --exclude=".hudson" \
- --exclude=".ivy2" \
- --exclude=".m2" \
- --exclude="lost+found" \
- --include="*config.xml" \
- --include="jobs/*/builds/*/log" \
- --include="users/*" \
- --include="*.hpi" \
- --include="*.jpi" \
- --include="*pinned" \
- --include="*disabled" \
- --include="scriptler/*" \
- --include="secrets/*" \
- --include="*.xml" \
- --include="*.key" \
- --exclude="*" \
- --prune-empty-dirs ${JENKINS_HOME}/ ${HG_REPOS_NAME}
- hg --cwd "${HG_REPOS_NAME}" add --all . ; \
- hg --cwd "${HG_REPOS_NAME}" ci -m "Jenkins ${JENKINS_MASTER} config backup @ $(date)" && \
- hg --cwd "${HG_REPOS_NAME}" push
- ## example
- # ./jenkins-git-backup.sh jenkins@10.0.2.196:/var/lib/jenkins git@git.oschina.net:choldrim/deepin-jenkins-git.git deepin-jenkins-git
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement