Advanced Jenkins
Backup and Configuration Management
Backing upRestoring Jenkins Demo
In this tutorial, you’ll learn how to backup and restore Jenkins using the Thin Backup plugin. With Thin Backup, you can schedule automated backups, keep only the most recent snapshots, and exclude unnecessary files to optimize storage.
Table of Contents
1. Install and Configure Thin Backup
- Navigate to Manage Jenkins > Manage Plugins, switch to the Available tab, and install Thin Backup.
- Once installed, go to Manage Jenkins > Configure System and scroll to the ThinBackup section.
Configure Backup Settings
Setting | Description |
---|---|
Backup Directory | /var/lib/jenkins/JENKINS_BACKUP (created automatically if missing) |
Schedule | Cron expressions for periodic backups |
Differential Backup | Enable to back up only changed data |
Max Backup Sets | Retain the latest N backups |
Exclude Patterns | Regex for files/folders to skip |
Archive as ZIP | Compress backup folders |
Include Build Archives | Optionally include full build artifacts |
Note
The Backup Directory
path must be writable by the Jenkins user. Ensure adequate disk space before scheduling large backups.
Click Apply to save your configuration.
2. Perform a Manual Backup
- Go to Manage Jenkins > ThinBackup.
- Click Backup Now.
To monitor progress, open Manage Jenkins > System Log > All Jenkins Logs. You should see entries like:
Nov 10, 2024 2:26:50 PM INFO jenkins.WebAppMain contextInitialized
Jenkins home directory: /var/lib/jenkins
Nov 10, 2024 2:26:51 PM INFO jenkins.InitReactorRunner$1 onAttained
Starting manual backup...
Nov 10, 2024 2:26:51 PM INFO jenkins.plugin.ThinBackup doBackup
No previous full backup found. Creating new full backup.
Found 16 jobs to backup.
Backing up job: example-job
Backing up folder job: org-folder/jobType
Backup process completed successfully.
Verify the backup files on your server:
ssh root@jenkins-controller-1
cd /var/lib/jenkins/JENKINS_BACKUP
ls
cd FULL-2024-11-10_16-37
ls
# audit-trail.xml
# backup-completed.info
# com.cloudbees.hudson.plugins.folder.config.AbstractFolderConfiguration.xml
# …
# jenkins.model.JenkinsLocationConfiguration.xml
3. Restore from Backup
- Delete a test job (e.g., Monitor Jenkins) to simulate data loss.
- In Manage Jenkins > ThinBackup, click Restore.
- Select the desired backup set (e.g.,
FULL-2024-11-10_16-37
) and confirm Restore. - Restart Jenkins to apply restored configurations.
After restart, the deleted job and its build history will reappear on the dashboard.
pipeline {
agent any
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
}
Warning
Restoring a backup overwrites your current Jenkins configuration. Always confirm you’re using the correct backup set.
4. Exclude Build Results
If you only need job configurations (not build artifacts), disable Include build results in the Thin Backup settings. This reduces backup size and speeds up the process.
Links and References
That’s it! You now know how to back up and restore your Jenkins instance efficiently using the Thin Backup plugin.
Watch Video
Watch video content