notsunohito / jenkins-backup-script

archive jenkins setting and plugins

Home Page:http://sue445.hatenablog.com/entry/2013/12/08/005317

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jenkins backup script

Build Status

Archive Jenkins settings and plugins

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

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

https://github.com/sue445/jenkins-backup-script.git
  • Recommended : specify Branch Specifier with latest release tag
  • latest tag is 0.0.9

0.0.3

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

UnitTest

install ruby 2.1+

bundle install
bundle exec rake test

Tips

rotate backup files

# keep backup with latest 30 days
find /path/to/backup_* -mtime +30 | xargs rm -f

Changelog

CHANGELOG.md

About

archive jenkins setting and plugins

http://sue445.hatenablog.com/entry/2013/12/08/005317

License:MIT License


Languages

Language:Ruby 72.2%Language:Shell 27.8%