If you are using Jenkins for a while then you must be aware about the importance of jobs related data and what can happen when the data is lost. This blog provides some ways through which backup and restoring in Jenkins can be carried out.
The data loss can be the result of hardware or software failure, data corruption, or a human-caused event, or accidental deletion of data.
The purpose of the backup is to create a copy of data that can be restored in the event of a primary data failure. Backup copies allow data to be restored from an earlier point in time to help the business recover from an unplanned event.
In Jenkins, all the settings, build logs, and archives of the artifacts are stored under the JENKINS_HOME directory as Jenkins doesn’t use any database. Setting access rights, selecting the necessary plugins and job configuration is quite a laborious process, so it’s a good idea to organize regular backups of all the necessary settings and parameters.
In this post we will be exploring 2 ways :
The simplest way is to just keep Jobs’s folder separately as backup and whenever it’s needed just copy it back.
As the build jobs created under this directory contains all the details of each and every individual jobs configured in the Jenkins install. The files related to jobs can be replicated to multiple locations.
But again it’s a manual task to copy the files from one location to another so instead let’s leverage Jenkins for B & R process by automating it.
Before proceeding initiate git repository and connect with it.
Now lets configure a freestyle project that takes regular backup .
0 12 * * * // will trigger at 12:00pm
45 12 * * * // will trigger at 12:45pm
Jenkins can be made enormously powerful by integrating several plugins. Here we will use a plugin for the backup management in Jenkins – ThinBackup plugin.
This plugin backs up the job specific configuration files.
#devops #jenkins #tech blogs #backup #devops #jenkins plugins #restore #thinbackup