Skip to content

Latest commit

 

History

History
90 lines (67 loc) · 2.25 KB

README.md

File metadata and controls

90 lines (67 loc) · 2.25 KB

Jenkins backup script

wercker status

Archive Jenkins settings and plugins

  • $JENKINS_HOME/*.xml
  • $JENKINS_HOME/jobs/*/*.xml
  • $JENKINS_HOME/nodes/*
  • $JENKINS_HOME/plugins/*.jpi
  • $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

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 jessie
  • CentOS 7.0

Testing

requirements Vagrant

gem install bundler -v 1.10.6
bundle install

vagrant up centos70
bundle exec rake itamae:centos70
bundle exec rake spec:centos70

Tips

rotate backup files

# keep backup with latest 30 days
find /path/to/backup_* -mtime +30 -delete

Restore commands

example

sudo /etc/init.d/jenkins stop
cd /path/to/backup_dir
tar xzvf backup.tar.gz
sudo cp -R jenkins-backup/* /path/to/jenkins/
sudo chown jenkins:jenkins -R /path/to/jenkins/
sudo /etc/init.d/jenkins start

Changelog

CHANGELOG.md