Skip to content

PublicStuff/jenkins-backup-script

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins backup script

Circle CI

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.6

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

master

full changelog

0.0.6

full changelog

0.0.5

full changelog

0.0.4

full changelog

  • copy failed when job name contains space (thx @rubenjgarcia)

0.0.3

full changelog

  • There are cases where the directory is not created

0.0.2

full changelog

  • remove archive file if exists

0.0.1

  • first release

Packages

No packages published

Languages

  • Ruby 54.5%
  • Shell 45.5%