Backup, Restore and Upgrade Jenkins: JENKINS_HOME, LTS Releases, Java 21 and Safe Plugin Updates
What Is JENKINS_HOME
JENKINS_HOME is the folder where Jenkins keeps everything: configuration, jobs, plugins, credentials and build history. Typical path: /var/lib/jenkins (Linux package) or /var/jenkins_home (Docker image).
text
JENKINS_HOME/
├─ config.xml global configuration
├─ credentials.xml encrypted credentials
├─ secrets/ encryption keys: needed to read credentials.xml
├─ jobs/NAME/config.xml job definition
├─ jobs/NAME/builds/ build history, logs, artifacts
├─ nodes/ agent definitions
├─ plugins/ installed plugins (*.jpi)
├─ users/ user data
├─ casc/ JCasC files (if used)
├─ workspace/ build workspaces (temporary, big)
└─ war/, logs/, caches rebuildable
| Back up | Usually skip |
config.xml, other *.xml in root | workspace/ (large, recreated) |
secrets/ (keep protected) | war/ (comes with the version) |
jobs/*/config.xml and chosen build history | caches/, logs/, fingerprints/ (optional) |
nodes/, users/, casc/ | Build logs of old builds, if you accept losing history |
plugins/ or a plugin list (plugins.txt) | |
Treat backups as secret: secrets/ plus credentials.xml can decrypt your credentials. Encrypt backups and restrict who can read them.
Backup Options
| Method | Notes |
| Volume or disk snapshot | Best for Docker and cloud: fast, consistent if done while idle |
| File copy with rsync or tar | Simple. Run when no builds are running or accept a small risk |
| ThinBackup plugin | UI-based scheduled backup of configuration, optional build data |
| Config in Git (JCasC + Job DSL + Jenkinsfiles) | The best backup is not needing one: rebuild from code. Keep only build history in snapshots |
bash
#!/usr/bin/env bash
# /usr/local/bin/backup-jenkins.sh
set -euo pipefail
SRC=/var/lib/jenkins
DEST=/backups/jenkins
STAMP=$(date +%F-%H%M)
mkdir -p "$DEST"
tar --exclude='workspace' --exclude='war' --exclude='caches' --exclude='logs' \
--exclude='jobs/*/builds/*/archive' \
-czf "$DEST/jenkins-$STAMP.tar.gz" -C "$SRC" .
gpg --batch --yes --symmetric --cipher-algo AES256 --passphrase-file /root/.backup-pass "$DEST/jenkins-$STAMP.tar.gz"
rm "$DEST/jenkins-$STAMP.tar.gz"
# keep 14 days
find "$DEST" -name 'jenkins-*.gpg' -mtime +14 -delete
bash
# Docker volume backup
docker run --rm -v jenkins_home:/data -v $PWD:/backup alpine \
tar czf /backup/jenkins_home-$(date +%F).tar.gz -C /data .
Restore and Test It
- Install the same or newer Jenkins and Java version on a new machine
- Stop Jenkins
- Extract the backup into
JENKINS_HOME and fix ownership: chown -R jenkins:jenkins /var/lib/jenkins
- Start Jenkins and open the UI
- Check credentials, a few jobs, agents and plugins. Run one build
bash
sudo systemctl stop jenkins
sudo tar xzf jenkins-2026-11-17.tar.gz -C /var/lib/jenkins
sudo chown -R jenkins:jenkins /var/lib/jenkins
sudo systemctl start jenkins
sudo journalctl -u jenkins -f
A backup you never restored is a hope: Practise a restore on a spare machine every quarter and write down how long it takes.
Jenkins Release Lines
| Line | Cadence | Use for |
| LTS (Long-Term Support) | A new baseline roughly every 12 weeks, plus point releases with fixes | Production |
| Weekly | New release every week | Testing new features, small labs |
- Use LTS for teams. Read the upgrade guide for each new LTS baseline on jenkins.io
- Check the current LTS number on the changelog-stable page before planning an upgrade
- Do not skip many baselines at once if you can avoid it, but you can jump if you test first
Java Requirement
Jenkins follows Java support rules that change over time. Recent LTS lines have dropped Java 17 and need Java 21 or Java 25. Always check the Java support policy page before upgrading Java or Jenkins.
| Task | Command |
| Check Java version | java -version |
| Check Jenkins version | Footer of the UI or curl -sI https://jenkins.example.com | grep -i x-jenkins |
| Docker image with Java 21 | jenkins/jenkins:lts-jdk21 |
Upgrade Java first when needed: If your current Jenkins runs on Java 17 and the new LTS requires 21, install Java 21 and switch the service before or together with the Jenkins upgrade. Agents may also need a newer Java for the remoting process.
Upgrade Steps (Package Install)
- Read the upgrade guide and the changelog for every version between yours and the target
- Check plugin compatibility (Manage Jenkins → Plugins) and update plugins first if recommended
- Back up
JENKINS_HOME
- Put Jenkins in quiet mode: Manage Jenkins → Prepare for Shutdown. Wait for builds to finish
- Upgrade the package or WAR, then restart
- Check the log for plugin or migration errors
- Run a few important jobs and review the Manage Jenkins warnings
bash
sudo apt-get update
sudo apt-get install --only-upgrade jenkins
sudo systemctl restart jenkins
sudo systemctl status jenkins --no-pager
Upgrade Steps (Docker)
bash
# Build a new image with the new tag and the same plugins.txt
docker build -t registry.example.com/ci/jenkins:2.580.2 .
docker stop jenkins && docker rm jenkins
docker run -d --name jenkins -p 8080:8080 -v jenkins_home:/var/jenkins_home registry.example.com/ci/jenkins:2.580.2
- Because data lives in the volume, the new container uses the old data
- Roll back by running the old image tag with a restored snapshot (the data may have been migrated to a newer format)
- On Kubernetes use the Helm chart and change
controller.image.tag
Update Plugins Safely
| Practice | Why |
| Keep a staging Jenkins with the same plugins | Test updates before production |
| Update in small batches | Easy to find a plugin that causes trouble |
| Read plugin release notes for breaking changes | Some change configuration or behavior |
Use Plugin Manager → Downgrade or restore the previous .jpi if needed | Quick fix for a bad update |
Pin versions in plugins.txt | Reproducible builds of the Jenkins image |
| Apply security updates quickly | Plugins are a common attack path |
Rollback
- Stop Jenkins
- Restore the backup taken before the upgrade (or the old volume snapshot)
- Start the previous version
- Open an incident note: what failed, what to test next time
Maintenance Checklist
- Weekly: check security advisories and plugin updates
- Monthly: clean old builds, check disk space, verify backups
- Quarterly: restore test, review agents and credentials, upgrade LTS if a new baseline is stable
- Yearly: review architecture, capacity and Java support dates
Practice Tasks
- Write and run the backup script on a lab Jenkins and list what is inside
- Restore the backup on another VM and run a job
- Create a staging copy and test a plugin update there
- Upgrade a Docker-based Jenkins to a newer LTS image tag and check the logs
- Practise a rollback with the old tag and the old snapshot
Conclusion
Back up JENKINS_HOME (especially config, secrets/ and job definitions), encrypt and test restores. Use LTS releases for production, meet the Java requirement (Java 21 or newer today), back up first, read upgrade guides, update plugins in small tested batches, and keep a rollback path.
Quick Summary: JENKINS_HOME map; what to back up; script + volume backup; restore steps; LTS vs weekly; Java 21; upgrade package/Docker; plugin update practice; rollback; checklist.