Backing up your data is a universally recommended practice, and your Jenkins server should be no exception. Fortunately, backing up Jenkins is relatively easy. In this section, we will look at a few ways to do this.
In the simplest of configurations, all you need to do is to periodically back up your JENKINS_HOME directory. This contains all of your build jobs configurations, your slave node configurations, and your build history. This will also work fine while Jenkins is running—there is no need to shut down your server while doing your backup.
The downside of this approach is that the JENKINS_HOME directory can contain a very large amount of data (see What’s in the Jenkins Home Directory). If this becomes an issue, you can save a little by not backing up the following directories, which contain data that can be easily recreated on-the-fly by Jenkins:
The exploded WAR file
You can also be selective about what you back up in your build jobs data. The $JENKINS_HOME/jobs directory contains job configuration, build history and archived files for each of your build jobs. The structure of a build job directory is illustrated in Figure 13-9.
Figure 13-9. The builds directory
To understand how to optimize your Jenkins backups, you need to understand ...