4.7.9.2.4. Backing up Jenkins

<< Click to Display Table of Contents >>

Navigation:  4. How to use Anatella? > 4.7. Batch Execution / Anatella command-line > 4.7.9. Running many Anatella graphs at regular interval > 4.7.9.2. Using Jenkins with Anatella >

4.7.9.2.4. Backing up Jenkins

 

In addition to disaster recovery, Jenkins backups are useful insurance against accidental configuration changes, which might be discovered long after they were made. A regular backup system lets you go back in time to find the correct settings.

 

There now exists many free Jenkins plugins that are automatically creating backups of Jenkins for you. Using a plugin to create Jenkins backups might be the easiest solution. As of november 2016, the available “backup plugins” are:
 

thinBackup

https://wiki.jenkins-ci.org/display/JENKINS/thinBackup

SCM Sync configuration plugin

https://wiki.jenkins-ci.org/display/JENKINS/SCM+Sync+configuration+plugin

PeriodicBackup plugin

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

 

 
Manually Creating Jenkins Backup

 

Jenkins stores everything under the Jenkins Home directory, $JENKINS_HOME, so the easiest way to back it up is to simply backup the entire $JENKINS_HOME directory. Even if you have a distributed Jenkins setup, you do not need to backup anything on the build agent side.

 

ANATEL~1_img8

To find the $JENKINS_HOME location, go to the Configure System menu.

 

 

Another backup planning issue is whether to do backup on live instances without taking Jenkins offline. Fortunately, Jenkins is designed so that doing a live backup works fine (configuration changes are atomic), so backups can be done without affecting a running instance.

 

ANATEL~1_img8

The following directories contain bits that can be easily recreated, so you

don’t need to include these in the backup:

* /war (exploded war)

* /cache (downloaded tools)

* /tools (extracted tools)

 
 

Optimization: Backup a Subset of $JENKINS_HOME

 

Although $JENKINS_HOME is the only directory you need to backup, there’s a catch: This directory can become rather large. To save space, consider what parts of this directory you really need to backup and back them up selectively.

 

The bulk of your data, including your job configuration and past filed records, lives in the /jobs directory. The /jobs directory holds information pertaining to all the jobs you create in Jenkins. Its directory structure looks like this:
 

  /jobs/*

  – builds                    (build records)

  – builds/*/archive          (archived artifacts)

  – workspace            (checked out workspace)

 
The /builds directory stores past build records. So, if you’re interested in configuration only, don’t backup the builds. Or perhaps you need to keep build records but can afford to throw away archived artifacts (which are actually usually produced binaries). You can do this excluding builds/*/archive; note that these artifacts can be pretty big, excluding them may introduce a substantial savings. Finally, the workspace directory contains the files that you check out for the version control systems.  Normally these directories can be safely thrown away. If you need to recover, Jenkins can always perform a clean checkout, so there’s usually no need to backup your workspace.