Jenkins backup script

Archive Jenkins settings and plugins

  • $JENKINS_HOME/*.xml
  • $JENKINS_HOME/plugins/*.jpi
  • $JENKINS_HOME/jobs//.xml

Usage

./jenkins-backup.sh /path/to/jenkins_home archive.tar.gz

# add timestamp suffix
./jenkins-backup.sh /path/to/jenkins_home backup_`date +"%Y%m%d%H%M%S"`.tar.gz

run with Jenkins Job

1. install Exclusive Execution Plugin

https://wiki.jenkins-ci.org/display/JENKINS/Exclusive+Execution+Plugin

2. New Job

img

3. Configure

Source Code Management > Repository URL

git@github.com:sue445/jenkins-backup-script.git

Recommended : specify Branch Specifier with latest release tag (ex. 0.0.2)

0.0.2

Build Triggers > Build periodically

img

Build Environment > Set exclusive Execution

img

Build > Execute shell

img

ex.

./jenkins-backup.sh $JENKINS_HOME /path/to/backup_`date +"%Y%m%d%H%M%S"`.tar.gz

Operability confirmed

  • Debian lenny
  • CentOS 6

Changelog

master

full changelog

0.0.2

full changelog

  • remove archive file if exixts

0.0.1

  • first release