Everything you have built in this course (the multibranch jobs, the build history, the users and roles from the previous lesson, the encrypted credentials, the configuration of linux-agent-01 and of tecnoshop-lib) lives in a single place: the jenkins_home volume. A failing disk, a mistaken docker compose down -v or an upgrade that corrupts the configuration would be enough to lose it. In this lesson Laura will design TecnoShop's backup policy: what is in JENKINS_HOME and what is worth backing up, which strategies exist (copying the volume's files, hot or cold, the ThinBackup plugin, disk snapshots and configuration as code), how to automate it with a commented script that rotates, encrypts and ships the backups off the server and, above all, how to restore, because a backup that has never been restored is just a hope.

Warning: Jenkins backups contain all of its secrets (and the keys to decrypt them) as well as users' personal data. Before applying this policy in a real environment, review with your organization's security or compliance lead where backups may be stored, how they are encrypted, who has access to them, how long they are kept and how they are destroyed.

What Is in JENKINS_HOME

Take a look at the contents of the volume:

docker compose exec jenkins-controller ls -la /var/jenkins_home
docker compose exec jenkins-controller du -sh /var/jenkins_home/* | sort -h
  • ls -la: lists files and directories, including hidden ones.
  • du -sh ... | sort -h: the size of each entry, sorted from smallest to largest. It will tell you right away what is taking up space (usually jobs/, workspace/, plugins/ or .m2/).

You will see something like this (abridged):

config.xml                       credentials.xml
hudson.plugins.git.GitTool.xml   jenkins.model.JenkinsLocationConfiguration.xml
org.jenkinsci.plugins.workflow.libs.GlobalLibraries.xml
jobs/   nodes/   plugins/   secrets/   users/   userContent/   fingerprints/
logs/   caches/  workspace/ tools/     updates/ war/   .m2/
secret.key   identity.key.enc   queue.xml   nodeMonitors.xml

What to Back Up and What Not To

Item What it contains Back it up?
config.xml Global configuration: security, built-in node executors, views Yes
*.xml in the root Configuration of each plugin and section: credentials.xml, Jenkins URL, tools, global libraries... Yes
jobs/*/config.xml Definition of each job (and of folders and multibranch jobs) Yes
jobs/*/builds/ and nextBuildNumber History: consoles, results, archived artifacts As needed: essential if the history has value (auditing, deployment traceability); it is what takes up the most space
jobs/<multibranch>/branches/ Jobs generated per branch and PR Optional: scanning recreates them, but without history
users/ Users of the own user database, password hashes, API tokens Yes
secrets/ and secret.key The instance's encryption keys Yes, essential (see the next section)
nodes/ Agent configuration (linux-agent-01) Yes
plugins/ .jpi files and their unpacked contents Better to keep the list (plugins.txt, in 05-04); until you have it, back up the .jpi files
fingerprints/ Artifact fingerprints (fingerprint: true) Yes, if you use artifact traceability
userContent/ Files published by hand in Jenkins Yes, if used
logs/ Jenkins logs and the Audit Trail log from 05-02 The audit log, yes; old technical logs, no
workspace/ Built-in node workspaces (from modules 1-4) No: they are regenerated with a checkout
caches/ Git caches for multibranch jobs and libraries No
.m2/ Maven cache from when builds ran on the controller No: it gets downloaded again
tools/ Tools installed automatically on the controller No
war/ The unpacked Jenkins WAR No: it comes with the image
updates/ Update center cache No

The general rule: back up what you cannot regenerate (configuration, secrets, history with value) and exclude what regenerates itself (workspaces, caches, tools, binaries).

The Keys That Decrypt the Credentials

Open credentials.xml and you will see that the secrets are not in clear text but stored as encrypted strings in braces ({AQAAABAAAAA...}). The encryption chain is:

flowchart LR
    MK["secrets/master.key<br/>(master key)"] -->|"decrypts"| HS["secrets/hudson.util.Secret<br/>(secrets key)"]
    HS -->|"decrypts"| CR["credentials.xml<br/>and other *.xml with secrets"]
  • secrets/master.key: the instance's master key.
  • secrets/hudson.util.Secret: the key used to encrypt credentials and other secrets in the configuration, itself encrypted with master.key.

Consequences:

  • If you restore credentials.xml without those two files, Jenkins will start, but it will not be able to decrypt any credential: github-tecnoshop, nexus-deployer and the rest will be useless and will have to be entered again.
  • If someone gets hold of the backup with those files, they can decrypt every credential. That is why backups are encrypted and stored with restricted access.
  • Some organizations store secrets/ separately from the rest of the backup (in a secrets manager or a vault). It is more secure, but it makes the restore more delicate: document clearly where each piece lives.

Backup Strategies

Strategy What it backs up Advantages Drawbacks
Copying the volume's files (tar) Whatever you choose from JENKINS_HOME Simple, no plugins, transparent restore You have to think about consistency; custom scripts
ThinBackup plugin Configuration (+ optional history) from within Jenkins Configured in the interface; differential backups The backup stays on the controller's disk; requires Jenkins to be running
Volume or disk snapshot The whole disk, in one go Very fast; fast restore Platform-dependent; also copies what is not needed; same provider
Configuration as code Configuration and jobs in Git Reviewable, reproducible Does not include history, local users or secret values

TecnoShop will combine the first one (a daily encrypted backup off the host) with configuration as code once it reaches 08-03.

Backing Up the Docker Volume with tar

The jenkins_home volume is managed by Docker; the portable way to back it up is to mount the volume in a temporary container that runs tar:

cd ~/tecnoshop-jenkins
mkdir -p backups
docker run --rm \
  -v jenkins_home:/var/jenkins_home:ro \
  -v "$(pwd)/backups":/backup \
  alpine:3 \
  tar czf /backup/jenkins_home-$(date +%Y%m%d-%H%M%S).tar.gz \
    --exclude='./workspace' \
    --exclude='./caches' \
    --exclude='./.m2' \
    --exclude='./tools' \
    --exclude='./war' \
    --exclude='./updates' \
    -C /var/jenkins_home .
ls -lh backups/
  • docker run --rm: creates a temporary container that is removed when it finishes.
  • -v jenkins_home:/var/jenkins_home:ro: mounts the Jenkins volume read-only (:ro): the backup cannot modify anything by mistake.
  • -v "$(pwd)/backups":/backup: mounts the backups directory on your machine; that is where the file will appear.
  • alpine:3: a minimal image that already includes tar and gzip.
  • tar czf <file>: c creates an archive, z compresses it with gzip and f gives the file name. $(date +%Y%m%d-%H%M%S) is evaluated by your shell and adds the date and time, for example jenkins_home-20261128-033000.tar.gz.
  • --exclude='./workspace' and the lines after it: skip what does not need to be backed up. The paths start with ./ because that is how they are stored in the archive.
  • -C /var/jenkins_home .: changes into the directory and archives its contents with relative paths (./config.xml, ./jobs/...), which makes it easy to restore anywhere.

Check that the archive is readable and contains what you expect:

tar tzf backups/jenkins_home-*.tar.gz | grep -E '^\./(config\.xml|secrets/master\.key|secrets/hudson\.util\.Secret|credentials\.xml)$'
  • tar tzf: lists the contents without extracting them.
  • grep -E: shows only the four critical paths. If any of them is missing, the backup is useless.

Add backups/ to the .gitignore of ~/tecnoshop-jenkins: these backups contain secrets.

Hot or Cold: Consistency

Mode How Consistency Impact
Cold docker compose stop jenkins-controller, back up, docker compose start jenkins-controller Complete: nobody writes during the backup Jenkins is unavailable for a few minutes
Hot Back up with Jenkins running Good for the configuration; builds in progress may be captured half-written None
Hot with Jenkins quiesced Prepare for Shutdown before backing up, cancel it afterward Nearly complete No new builds start during the backup

Details that justify a hot backup:

  • Jenkins saves its configuration XML files by first writing a temporary file and then renaming it, so capturing a half-written config.xml is very rare.
  • What can be incomplete is the directory of a build in progress. After a restore, that build will show up as interrupted; it does not affect anything else.

TecnoShop's decision: a daily hot backup at 03:30, when the nightly builds scheduled between 02:00 and 03:00 (H 2 * * 1-5) have already finished, and a cold backup before every upgrade (05-04).

The ThinBackup Plugin

ThinBackup makes backups from within Jenkins itself. Once installed, it appears in Manage Jenkins → ThinBackup, with Backup Now, Restore and Settings. The main options:

Option Suggested value Explanation
Backup directory /var/jenkins_home/thinbackup or, better, a separate volume Where it stores the backups
Backup schedule for full backups H 3 * * 0 Weekly full backup (Jenkins cron syntax)
Backup schedule for differential backups H 3 * * 1-6 Only what has changed since the last full backup
Max number of backup sets 4 Sets (full + differentials) it keeps
Files excluded from backup (regular expression) (as needed) Files to skip
Wait until Jenkins is idle to perform a backup Checked Waits until there are no builds
Force Jenkins to quiet mode after specified minutes 120 If there are still builds after that time, it puts Jenkins into quiet mode
Backup build results / Backup build archive As needed Include history and artifacts
Backup plugins archives Checked Includes the .jpi files
Move old backups to ZIP files Checked Compresses older backups

Limitations you should be aware of:

  • By default the backup stays on the same disk (or volume) as Jenkins: if the disk is lost, both are lost. You need an additional process to ship it off the server.
  • It does not encrypt the backups.
  • It requires Jenkins to be running to back up and, to restore from the interface, a working Jenkins with the plugin installed.
  • It is one more plugin to maintain and upgrade.

It is a good option for installations without access to the server's operating system. TecnoShop does have that access and prefers the script, which does not depend on Jenkins working.

Volume and Disk Snapshots

In the cloud, the disk where JENKINS_HOME lives (an EBS volume on AWS, a managed disk on Azure, a persistent disk on Google Cloud) can be backed up with snapshots:

  • They are fast, and restoring consists of creating a disk from the snapshot: the RTO is low.
  • They are crash-consistent: equivalent to pulling the machine's plug at that instant. With Jenkins this is usually enough, for the reasons explained in the consistency section.
  • They copy everything, including workspaces and caches.
  • They stay in the same account and provider: if someone compromises or deletes the account, they go with it. Supplement them with a copy in another account or region.

Configuration as Code: a Complement, Not a Substitute

In module 8 you will describe the installation in versioned files: JCasC for the global configuration, Job DSL for the jobs and the Jenkinsfiles you already have in each repository (08-03). With that, recreating an empty Jenkins with the same configuration will be a matter of minutes. But Git will not store:

  • The build history: consoles, results, archived artifacts, fingerprints.
  • The credential values (in JCasC they are referenced, not written out).
  • The users of the own user database, with their API tokens.
  • The audit log.

That is why configuration as code reduces what depends on the backup, but does not replace it.

TecnoShop's backup-jenkins.sh Script

Laura installs this script on the server that hosts Jenkins, at /usr/local/bin/backup-jenkins.sh, owned by root and with permissions 750:

#!/usr/bin/env bash
# backup-jenkins.sh - Daily encrypted backup of the jenkins_home volume (TecnoShop)
set -euo pipefail

VOLUME="jenkins_home"
LOCAL_DEST="/srv/backups/jenkins"
LOCAL_RETENTION_DAYS=7
REMOTE_DEST="[email protected]:/backups/jenkins/"
KEY_FILE="/root/.config/tecnoshop/jenkins-backup-key"
TIMESTAMP="$(date +%Y%m%d-%H%M%S)"
ARCHIVE="jenkins_home-${TIMESTAMP}.tar.gz"

log() { echo "[$(date -Is)] $*"; }

mkdir -p "$LOCAL_DEST"
log "Starting backup of volume ${VOLUME}"

docker run --rm \
  -v "${VOLUME}":/var/jenkins_home:ro \
  -v "${LOCAL_DEST}":/backup \
  alpine:3 \
  tar czf "/backup/${ARCHIVE}" \
    --exclude='./workspace' --exclude='./caches' --exclude='./.m2' \
    --exclude='./tools' --exclude='./war' --exclude='./updates' \
    -C /var/jenkins_home .

for critical in ./config.xml ./secrets/master.key ./secrets/hudson.util.Secret; do
  tar tzf "${LOCAL_DEST}/${ARCHIVE}" | grep -qx "$critical" \
    || { log "ERROR: ${critical} is missing from the backup"; exit 1; }
done
log "Backup verified: $(du -h "${LOCAL_DEST}/${ARCHIVE}" | cut -f1)"

gpg --batch --yes --pinentry-mode loopback \
    --passphrase-file "$KEY_FILE" \
    --symmetric --cipher-algo AES256 \
    --output "${LOCAL_DEST}/${ARCHIVE}.gpg" "${LOCAL_DEST}/${ARCHIVE}"
rm -f "${LOCAL_DEST}/${ARCHIVE}"
sha256sum "${LOCAL_DEST}/${ARCHIVE}.gpg" > "${LOCAL_DEST}/${ARCHIVE}.gpg.sha256"
log "Backup encrypted"

rsync -a "${LOCAL_DEST}/${ARCHIVE}.gpg" "${LOCAL_DEST}/${ARCHIVE}.gpg.sha256" "$REMOTE_DEST"
log "Backup sent to ${REMOTE_DEST}"

find "$LOCAL_DEST" -name 'jenkins_home-*.tar.gz.gpg*' -mtime +"$LOCAL_RETENTION_DAYS" -delete
log "Local rotation complete (keeping ${LOCAL_RETENTION_DAYS} days)"
log "Backup finished"

Line by line:

  • #!/usr/bin/env bash: runs the script with Bash.
  • set -euo pipefail: -e stops the script at the first command that fails; -u treats using an undefined variable (for example, a misspelled name) as an error; -o pipefail makes a pipeline fail if any of its commands fails, not just the last one. Without this, a failed tar could end with a misleading "Backup finished".
  • Variable block: everything configurable is at the top. REMOTE_DEST is a fictitious TecnoShop backup server, reachable over SSH with a key (the key of the host's root user, not a Jenkins credential). KEY_FILE contains the encryption passphrase, with permissions 600.
  • log() { ... }: a small function that prefixes each message with an ISO date and time; the cron log will be readable.
  • mkdir -p: creates the local directory if it does not exist; -p does not fail if it already exists.
  • docker run ... tar czf ...: the backup explained in the previous section.
  • for critical in ... loop: lists the backup's contents and looks for each critical file. grep -qx searches quietly (-q) for an exact line (-x). If any is missing, it logs the error and exits with code 1. A backup without master.key is worse than none at all, because it gives a false sense of security.
  • du -h ... | cut -f1: logs the size; a backup that is suddenly half the size it was yesterday is a red flag.
  • gpg --batch ... --symmetric --cipher-algo AES256: encrypts with a passphrase (AES-256 symmetric encryption). --batch and --pinentry-mode loopback let it read the passphrase from a file with no interaction; --yes overwrites without asking.
  • rm -f of the .tar.gz: does not leave the unencrypted backup on disk.
  • sha256sum ... > .sha256: stores a checksum to verify that the file reaches its destination intact.
  • rsync -a ... "$REMOTE_DEST": sends the encrypted backup and its checksum to another server over SSH. -a preserves timestamps and permissions.
  • find ... -mtime +7 -delete: rotation: deletes local backups older than 7 days. Long-term retention (for example, 30 daily and 12 monthly backups) is applied by the backup server, which is the one with the space.

The 3-2-1 Rule

The script implements the classic backup rule:

Rule At TecnoShop
3 copies of the data The jenkins_home volume, the local backup and the remote one
On 2 different media The Jenkins server's disk and the backup server's disk
1 copy off-site backup.tecnoshop.local is in another data center (in the cloud, another region or account)

The gpg passphrase is as important as the backup: store it in the corporate secrets manager. Without it, the encrypted backups cannot be restored.

Scheduling: System cron or a Jenkins Job

Laura schedules it with the system cron, in /etc/cron.d/backup-jenkins:

# m  h  dom mon dow  user     command
30   3  *   *   *    root     /usr/local/bin/backup-jenkins.sh >> /var/log/backup-jenkins.log 2>&1
  • 30 3 * * *: every day at 03:30 (server time). Files in /etc/cron.d/ have an extra field with the user.
  • >> /var/log/backup-jenkins.log 2>&1: appends both standard output and error output to the log.
  • Modern alternative: a systemd timer, which also records the result in journalctl.

So why not a Jenkins job that backs Jenkins up? It is tempting (history, notifications, a Build Now button), but it is debatable:

For Against
History and logs in the interface If Jenkins is down or corrupted, there is no backup, exactly when you need it most
Built-in failure notifications The build needs access to the controller's volume or to the host's Docker socket: it breaks the isolation you achieved in 05-01
Easy to run by hand The backup server credential now lives in Jenkins, and the backup would include... that credential

TecnoShop uses cron and checks from the outside that the backup has been made (monitoring is covered in 05-05).

RPO and RTO

Concept Question Depends on
RPO (Recovery Point Objective) How much data can I afford to lose? How often backups are made
RTO (Recovery Time Objective) How long can Jenkins be out of service? How fast and well-rehearsed the restore is
Strategy Typical RPO Typical RTO
Daily backup with tar Up to 24 hours 1-2 hours (download, decrypt, extract, start)
Daily differential ThinBackup Up to 24 hours 1-2 hours
Hourly snapshots Up to 1 hour Minutes
Configuration as code only Configuration: the last commit; history: all lost Minutes to hours

TecnoShop's targets: an RPO of 24 hours (losing a day of history is acceptable; the configuration barely changes and the Jenkinsfiles are in Git) and an RTO of 4 hours. An RTO is only real if you have measured it in a drill.

Full Restore into an Isolated Container

Always restore into a separate environment first, never on top of the installation in use. The procedure works both for a real disaster and for testing the backups.

Step 1: Get and Decrypt the Backup

cd ~/tecnoshop-jenkins/backups
sha256sum -c jenkins_home-20261128-033000.tar.gz.gpg.sha256
gpg --output jenkins_home-20261128-033000.tar.gz --decrypt jenkins_home-20261128-033000.tar.gz.gpg
  • sha256sum -c: checks that the file matches its checksum (OK).
  • gpg --decrypt: asks for the passphrase and produces the .tar.gz.

Step 2: Create an Empty Volume and Extract

docker volume create jenkins_home_restored
docker run --rm \
  -v jenkins_home_restored:/var/jenkins_home \
  -v "$(pwd)":/backup:ro \
  alpine:3 \
  tar xzf /backup/jenkins_home-20261128-033000.tar.gz -C /var/jenkins_home
  • A new volume, jenkins_home_restored: the original is left untouched.
  • tar xzf ... -C: extracts into the volume. Because it runs as root, tar preserves the files' original owner (the jenkins user, UID 1000), which is the one the image needs.

Step 3: Check the Version and Start

docker run --rm -v jenkins_home_restored:/var/jenkins_home:ro alpine:3 \
  grep -m1 '<version>' /var/jenkins_home/config.xml

docker run -d --name jenkins-restored \
  -p 8090:8080 \
  -v jenkins_home_restored:/var/jenkins_home \
  jenkins/jenkins:lts-jdk21
docker logs -f jenkins-restored
  • The first command shows the Jenkins version that wrote the backup. Restore with the same version or a later one; never with an earlier one, which might not understand the configuration. Once you have your own image in 05-04, use the same tag.
  • --name jenkins-restored -p 8090:8080: a different name and a different port (8090; 8081 is used by orders-api locally). It is not part of docker-compose.yml: it is temporary.
  • docker logs -f: wait for Jenkins is fully up and running. You will not see the setup wizard: this is the restored instance.

Step 4: Isolate It

The restored copy is a twin of production: it has the same jobs with their cron triggers, the same credentials and the same node secrets.

  • Thanks to 05-01, the built-in node has 0 executors and linux-agent-01 is only connected to production: any builds that get triggered will stay in the queue without running. You can clear the queue without any problem.
  • Do not connect any agent to the copy: the linux-agent-01 secret is valid there too, because its keys were restored. An agent connected to the copy could run deployments.
  • In Manage Jenkins → System → Jenkins URL, set http://localhost:8090/ so that links point to the copy.
  • In a real test restore, start the container on a network with no Internet access or disable the triggers, especially once notifications and deployments exist (modules 6 and 7).

Step 5: Verify

Check How What it proves
Sign in as laura, diego and marta Log in at http://localhost:8090 users/ and security have been restored
Jobs and history Dashboard, orders-api, previous builds and their consoles jobs/ is complete
Credentials decrypt Scan Multibranch Pipeline Now on orders-api: it must reach the private repository with github-tecnoshop master.key and hudson.util.Secret are fine
Nodes Manage Jenkins → Nodes: linux-agent-01 exists (disconnected) nodes/
Plugins No loading errors in Manage Jenkins Plugins consistent with the version
Unrecognized data Manage Jenkins → Manage Old Data is empty No plugin is missing

Step 6: Clean Up

docker rm -f jenkins-restored
docker volume rm jenkins_home_restored
rm ~/tecnoshop-jenkins/backups/jenkins_home-20261128-033000.tar.gz

The last command deletes the decrypted backup. In a real disaster, instead of cleaning up, you would point the jenkins-controller service at the restored volume (or extract the backup into a new jenkins_home volume) and reconnect the agents.

Restoring a Single Job

A common case: someone has deleted orders-api-build or broken its configuration. There is no need to restore everything.

cd ~/tecnoshop-jenkins/backups
mkdir -p restore
tar xzf jenkins_home-20261128-033000.tar.gz -C restore ./jobs/orders-api-build
docker cp restore/jobs/orders-api-build jenkins-controller:/var/jenkins_home/jobs/
docker compose exec -u root jenkins-controller chown -R jenkins:jenkins /var/jenkins_home/jobs/orders-api-build
  • tar xzf ... ./jobs/orders-api-build: extracts only that directory (configuration and history).
  • docker cp: copies the directory into the container. The files arrive owned by root.
  • chown -R jenkins:jenkins: gives ownership back to the jenkins user; without it, Jenkins could not write new builds.

Then use Manage Jenkins → Reload Configuration from Disk (or a safe restart with /safeRestart) so that Jenkins reads it. If you only want to recover the configuration, extract just ./jobs/orders-api-build/config.xml. For a multibranch job like orders-api, its config.xml is enough: scanning recreates the branches (without history).

Common Mistakes and Tips

  • Never having restored a backup: the most serious mistake. Schedule a drill at least once a quarter and write down how long it takes.
  • Backing up without secrets/: Jenkins starts, but every credential is useless.
  • Leaving unencrypted backups on disk or on shared storage: they contain everything needed to decrypt every TecnoShop secret.
  • Keeping the backup only on the same server (or the same volume, as ThinBackup does by default).
  • Restoring with an earlier Jenkins version than the one that made the backup.
  • Restoring on top of production "to save time": if the backup is bad, you also lose what you had.
  • Backing up workspace/ and .m2/: it multiplies the size and the time without adding anything.
  • Tip: keep the restore procedure in writing, alongside the backups and outside Jenkins. In a disaster, documentation that lives in the Jenkins that just went down is no use.

Exercises

Exercise 1. Install backup-jenkins.sh on your machine, adapted to the lab environment: LOCAL_DEST in ~/tecnoshop-jenkins/backups, without rsync (replace it with a copy to another disk or directory) and with your own key file. Run it twice and check the verification, the encryption and the checksum. What happens if you temporarily change ./secrets/master.key to ./secrets/master.keys in the critical files loop?

Exercise 2. Disaster drill. Assume the disk where jenkins_home lives has died. With only the latest encrypted backup and its passphrase, bring up jenkins-restored on port 8090 and complete the verification table. Measure the time from when you start until you sign in and the orders-api scan works. Do you meet the 4-hour RTO? Which builds would you have lost according to the RPO?

Exercise 3. Diego has changed the configuration of orders-api-smoke and it no longer works. Recover only its config.xml from last night's backup without touching its history. Write the commands.

Solutions

Solution 1. With the changes, the script creates a .tar.gz.gpg and its .sha256 in ~/tecnoshop-jenkins/backups on every run, and the log shows "Backup verified" with the size. With ./secrets/master.keys, grep -qx does not find that line, the script logs ERROR: ./secrets/master.keys is missing from the backup, exits with code 1 (echo $?) and does not encrypt or send anything; an unencrypted .tar.gz is left behind, which you should delete. A possible improvement: use trap to delete the .tar.gz if the script fails partway through. Put the correct name back when you are done.

Solution 2. The steps are the ones from the lesson: sha256sum -c, gpg --decrypt, docker volume create, extraction with tar xzf in an alpine:3 container, checking <version> and docker run of jenkins-restored on port 8090. In the verification, the decisive point is that the orders-api scan reaches the private repository: it proves that the credentials decrypt. The usual time on a laptop is 10 to 20 minutes, well below the RTO; in a real disaster you have to add getting hold of a server, the passphrase and the remote backup. According to the RPO, you would have lost the builds and configuration changes made after 03:30 on the day of the last backup. Write down whatever gave you trouble (did you know where the passphrase was?): that is the real outcome of the drill.

Solution 3.

cd ~/tecnoshop-jenkins/backups
gpg --output last-night.tar.gz --decrypt jenkins_home-20261128-033000.tar.gz.gpg
mkdir -p restore
tar xzf last-night.tar.gz -C restore ./jobs/orders-api-smoke/config.xml
docker cp restore/jobs/orders-api-smoke/config.xml jenkins-controller:/var/jenkins_home/jobs/orders-api-smoke/config.xml
docker compose exec -u root jenkins-controller chown jenkins:jenkins /var/jenkins_home/jobs/orders-api-smoke/config.xml
rm last-night.tar.gz

Then use Manage Jenkins → Reload Configuration from Disk. The history is untouched because you have only replaced config.xml. With the Job Configuration History plugin, mentioned in 05-02, you could have done this from the interface, and also seen exactly what changed.

Conclusion

You now know what is in JENKINS_HOME and what is worth backing up: the global and plugin configuration, the jobs, the users, the nodes, any history that has value and, above all, secrets/master.key and secrets/hudson.util.Secret, without which restored credentials are useless; and what is not: workspaces, caches, .m2, tools and the WAR. You know the strategies (copying the volume with tar, hot or cold, ThinBackup, snapshots and configuration as code as a complement), and TecnoShop has a concrete policy: every night backup-jenkins.sh makes a backup that is verified, encrypted and shipped off the server following the 3-2-1 rule, scheduled with cron rather than from Jenkins itself, with a 24-hour RPO and a 4-hour RTO that you have measured by restoring into jenkins-restored, isolated from production; and you know how to recover a single job. With a reliable backup in place, Laura can tackle the operation that has prompted more emergency backups than any other in Jenkins history: upgrading the core and the plugins. You will do it reproducibly and safely in Upgrading Jenkins and Maintaining Plugins.

© Copyright 2026. All rights reserved