build. If you are not interested in restoring build history or past artifacts, you don’t need to store this
directory. If you are, read on! In each of these directories, you will find the build history (stored in the
form of XML files such as JUnit test results) and archived artifacts. Jenkins uses the XML and text
files to produce the graphs it displays on the build job dashboard, so if these are important to you, you
should store these files. The archive directory contains binary files that were generated and stored by
previous builds. These binaries may or may not be important to you, but they can take up a lot of space,
so if you exclude them from your backups, you may be able to save a considerable amount of space.
Just as it is wise to make frequent backups, it is also wise to test your backup procedure. With Jenkins,
this is easy to do. Jenkins home directories are totally portable, so all you need to do to test your backup is
to extract your backup into a temporary directory and run an instance of Jenkins against it. For example,
imagine we have extracted our backup into a temporary directory called /tmp/jenkins-backup. To
test this backup, first set the JENKINS_HOME directory to this temporary directory:
$ export JENKINS_HOME=/tmp/jenkins-backup
Then simply start Jenkins on a different port and see if it works:
$ java -jar jenkins.war --httpPort=8888
You can now view Jenkins running on this port and make sure that your backup worked correctly.
13.4.2. Using the Backup Plugin
The approach described in the previous section is simple enough to integrate into your normal backup
procedures, but you may prefer something more Jenkins-specific. The Backup plugin (see Figure 13.10,
“The Jenkins Backup Manager Plugin”) provides a simple user interface that you can use to back up
and restore your Jenkins configurations and data.
Figure 13.10. The Jenkins Backup Manager Plugin