8
votes

I'm trying to work out a way to backup and restore jenkins so we can provision a new jenkins automatically.

I cannot work out a way to backup+restore /path/to/jenkins/plugins without including the binaries. We would like the backup to be in xml file format, just as everything else in jenkins. My assumption was that we could somehow backup xml files, and jenkins could restore the plugin binaries if they are missing, since it has access to maven.

I would prefer to avoid using config management tools to install plugins, as I then I have to manage versions of plugins in a way that feels too controlled. I'm happy to just backup what ever is there, and restore it elsewhere when needed. The developers should be free to install plugins, without involving me or puppet.

Googl'ing the issue is difficult since "plugin" is used in so many other contexts.

Below link says it governs plugins as well, but I cannot see how this is - maybe I'm missing something.

http://jenkins-ci.org/content/keeping-your-configuration-and-data-subversion

I have ported the idea to use git and it generally works, except that plugins do not re-appear by magic on the new machine - only the default plugins come back.

Can anyone suggest?

3
The "keep your configuration backups in subversion" script handles plugin configuration (generally XML files in the Jenkins home directory), not the plugins themselves.Dave Bacher
Has anyone used grunt-jenkins ? This looks promising. Specifically it can "install plugins from pipeline-directory/plugins.json"Jepper
I ended up rsync'ing to an s3fs mounted s3 bucket. I set version history on the bucket. I was hesitant to implement s3fs, but it work surprisingly well. I have a exclude list so we don't rsync zips, wars etc.Jepper

3 Answers

7
votes

If you don't want to back up the plugin binary files, you can use the Jenkins REST API to get the list of current plugins:

http://jenkins:8080/pluginManager/api/json?tree=plugins[shortName,version]&pretty=true.

(You can use tree=plugins[*] to see a more complete list of fields in the API.)

Save this data as part of your configuration backup and use the Jenkins API to restore the plugins when you're re-deploying.

There's additional documentation and how to update plugins on the pluginManager API page: http://jenkins:8080/pluginManager/api

1
votes

The best idea I've come up with to date, is to split the instance into an OS disk and a Jenkins disk mounted on /var/lib/jenkins. Use your cloud provider's snapshot feature to backup the jenkins disk periodically. Jenkins is for many organisations I believe, always going to be a "flake" server, or a pet, that needs nurturing and does not benefit much from automation, other than what is used to maintain the OS.

0
votes

To backup Jenkins components, you can use Handy Backup. A best practice is to set up at least daily backup in a differential or mixed (full/differential) mode. This is an advantage before using any plug-in, due to assured regularity of backups.