Install and Configure Jenkins thinBackup and Upgrade Jenkins

Today I get opportunity to upgrade jenkins, Jenkins is a very important tool for continuous integration and continuous delivery. All the Jenkins data i.e, jobs and configs are stored in JENKINS_HOME directory. Taking a periodic backup of JENKINS_HOME directory is one the best practice of Jenkins Managment. Jenkins can be extended with plugins for extra features. There is a plugin called Jenkins thinBackup Plugin. This helps in automate the backup of JENKINS_HOME Directory.

Install and Configure Jenkins thinBackup Plugin for Backup Strategy

Steps to Install the thinBackup Plugin.
1) Go to Manage Jenkins
2) Click Manage Plugins
3) Under Available Plugins tab select ThinBackup
4) Click on Install without restart button.

Steps to Configure thinBackup Plugin
1) Go to Manage Jenkins
2) Click thinBackup option
3) Click settings to configure the backup options as shown below.

Jenkins ThinBackup Plugin
4) Schedule the automated backups as shown sample below. All the configuration is self-explanatory.

Jenkins ThinBackup Configuration

Download New Jenkins War File

cd /downloads  wget http://updates.jenkins-ci.org/download/war/2.9/jenkins.war

Install the New Jenkins War File

Copy the previous version of jenkin

cp /usr/share/jenkins/jenkins.war ~/jenkins.war.previous.version

Next, copy the newly downloaded war file to the  /usr/share/jenkins directory.

cp /downloads/jenkins.war /usr/lib/jenkins/
Next, restart the Jenkins service as shown below. Use either systemctl or service command.

service jenkins stop
service jenkins start

service jenkins status

● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
   Active: active (exited) since Tue 2017-11-14 08:46:08 UTC; 17s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4424 ExecStop=/etc/init.d/jenkins stop (code=exited, status=0/SUCCESS)
  Process: 4523 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)

Nov 14 08:46:07 ip-10-0-1-120 systemd[1]: Starting LSB: Start Jenkins at boot time...
Nov 14 08:46:07 ip-10-0-1-120 jenkins[4523]: Correct java version found
Nov 14 08:46:07 ip-10-0-1-120 jenkins[4523]:  * Starting Jenkins Automation Server jenkins
Nov 14 08:46:07 ip-10-0-1-120 su[4561]: Successful su for jenkins by root
Nov 14 08:46:07 ip-10-0-1-120 su[4561]: + ??? root:jenkins
Nov 14 08:46:07 ip-10-0-1-120 su[4561]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Nov 14 08:46:08 ip-10-0-1-120 jenkins[4523]:    ...done.
Nov 14 08:46:08 ip-10-0-1-120 systemd[1]: Started LSB: Start Jenkins at boot time.

Store Jenkins Backups in Repository Manager like Nexus

After installing and configuring the Jenkins thinBackup plugin store the backup file in some repository manager like Nexus. So that even the server crashes, we will have the backups in one more place from where we can restore.Create a Jenkins backup job and in nexus a repo to store Jenkins Backup. Schedule the Jenkins backup job to push the backup zip file to nexus Jenkins Backup repo. Then schedule a Schedule Task in nexus for periodic cleanup of Jenkins Backup repo.

Conclusion :

We hope this Jenkins Backup strategy helps you to configure Jenkins. We shared one way of doing Jenkins Backup. There are many plugins for backup or you can write your own script to backup the JENKINS_HOME directory. We prefer thinBackup Plugin for taking Jenkins backup and then store the backups in Nexus. IF you are using some other backup strategy please share in comments, which will we be helpful to readers.

​​

Popular posts from this blog

Shrink you container size up to 95%.

alma linux: dnf Module yaml error: Unexpected key in data