Backup, Restore and Upgrade Jenkins: JENKINS_HOME, LTS Releases, Java 21 and Safe Plugin Updates

CI CD Pipelines with Jenkins 35 min min read Updated: Nov 17, 2026 Intermediate
Backup, Restore and Upgrade Jenkins: JENKINS_HOME, LTS Releases, Java 21 and Safe Plugin Updates
Intermediate Topic 2 of 3

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 upUsually skip
config.xml, other *.xml in rootworkspace/ (large, recreated)
secrets/ (keep protected)war/ (comes with the version)
jobs/*/config.xml and chosen build historycaches/, 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

MethodNotes
Volume or disk snapshotBest for Docker and cloud: fast, consistent if done while idle
File copy with rsync or tarSimple. Run when no builds are running or accept a small risk
ThinBackup pluginUI-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

  1. Install the same or newer Jenkins and Java version on a new machine
  2. Stop Jenkins
  3. Extract the backup into JENKINS_HOME and fix ownership: chown -R jenkins:jenkins /var/lib/jenkins
  4. Start Jenkins and open the UI
  5. 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

LineCadenceUse for
LTS (Long-Term Support)A new baseline roughly every 12 weeks, plus point releases with fixesProduction
WeeklyNew release every weekTesting 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.

TaskCommand
Check Java versionjava -version
Check Jenkins versionFooter of the UI or curl -sI https://jenkins.example.com | grep -i x-jenkins
Docker image with Java 21jenkins/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)

  1. Read the upgrade guide and the changelog for every version between yours and the target
  2. Check plugin compatibility (Manage Jenkins → Plugins) and update plugins first if recommended
  3. Back up JENKINS_HOME
  4. Put Jenkins in quiet mode: Manage Jenkins → Prepare for Shutdown. Wait for builds to finish
  5. Upgrade the package or WAR, then restart
  6. Check the log for plugin or migration errors
  7. 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

PracticeWhy
Keep a staging Jenkins with the same pluginsTest updates before production
Update in small batchesEasy to find a plugin that causes trouble
Read plugin release notes for breaking changesSome change configuration or behavior
Use Plugin Manager → Downgrade or restore the previous .jpi if neededQuick fix for a bad update
Pin versions in plugins.txtReproducible builds of the Jenkins image
Apply security updates quicklyPlugins are a common attack path

Rollback

  1. Stop Jenkins
  2. Restore the backup taken before the upgrade (or the old volume snapshot)
  3. Start the previous version
  4. Open an incident note: what failed, what to test next time

Maintenance Checklist

  1. Weekly: check security advisories and plugin updates
  2. Monthly: clean old builds, check disk space, verify backups
  3. Quarterly: restore test, review agents and credentials, upgrade LTS if a new baseline is stable
  4. Yearly: review architecture, capacity and Java support dates

Practice Tasks

  1. Write and run the backup script on a lab Jenkins and list what is inside
  2. Restore the backup on another VM and run a job
  3. Create a staging copy and test a plugin update there
  4. Upgrade a Docker-based Jenkins to a newer LTS image tag and check the logs
  5. 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.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators