How To Backup Jenkins Automatically

In this guide , We will learn how to setup a strategy to backup the jenkins using a plugin.

What Is Jenkins?

Jenkins is an open source continuous integration server , which is written in java.

It is used to automate the tasks which we run it manually as a everyday tasks.

It is used to deploy applications into the server automatically whenever commit occurs.

How To Backup Jenkins?

To backup Jenkins and the configuration of the Jenkins such as job items , build history and other information , We are going to install a plugin and then configure the settings for the backup such as backup directory , Cron expression , Retention period for backup.

Before Installing the plugin , We have to create a folder for the backup and the jenkins user folder should have the permission to write the files into the folder.

To Install Plugin , Login to Jenkins , In the left navigation pane , Choose Manage Jenkins

Scroll down and choose Manage Plugins

You will see the lists of available options such as Updates , Available , Installed and Advanced.

Choose Available , and In the search box , Type Thinbackup ,

Select the plugin and Click Install without restart

One the plugin is installed , Login to the jenkins server and restart the jenkins service , using the below Command ,

systemctl restart jenkins

Once the Jenkins process is restarted , It will take few seconds for the jenkins to be live again.

Now Go to Jenkins Home page , Choose Manage Jenkins

Scroll down and You will see the ThinBackup

Click ThinBackup , You will see the following screen.

As I informed earlier , First , We have to configure the backup settings.

Choose Settings ,

For Backup directory , provide the full path to the backup folder which you have created in the server.

Backup schedule for full backups , Provide the Cron expression as per your requirement.

For example : 0 11 * * 1-5 , The backup for jenkins will be initiated everyday of week at 11 PM from Monday to Friday.

Max number of backup sets , Provide the number of days backup you want it to be stored in the server.

For example , Max number of backup sets = 5 , Only last 5 backups will be saved.

You can check and enable other available options If required.

And Click Save. Now Click Backup Now , To initiate the backup manually.

The backup will the stored in the folder which you have created.

The name of the backup files as follows: FULL-2020-01-22_13-53

The filename will appended with the date and the time , the backup is created.

Conclusion

Now that We have successfully implemented a plugin to create a backup of Jenkins as per the scheduled Cron expression.

Hope you found it helpful.Thanks for reading this article.

Please do check out my other publications.