4.8.7. Backing up Jenkins

<< Click to Display Table of Contents >>

Navigation:  4. How to use Anatella? > 4.8. Scheduling Anatella Graphs >

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

 

 
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: you can usually delete this from backup)

  – builds/*/archive          (archived artifacts: delete this from backup)

  – workspace            (checked-out workspace from github: delete this from backup)

 

 
The /builds directory stores past build records. So, if you’re interested in configuration only, don’t backup the builds. The workspace directory contains the files that you check out for the version control systems.  Normally these directories can be safely thrown away.