In this guide, we’ll walk through manually backing up your Jenkins home directory and validating the archive in an isolated environment. This process helps ensure you can fully restore Jenkins configuration, jobs, plugins, and credentials in the event of a failure.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
1. Locate the Jenkins Home Directory
List the contents of/var/lib and filter for “jenkins” to identify the home directory and any existing backups:
- jenkins/ – the active Jenkins home directory.
- Any previous archives like
jenkins-EOF.tar.gz.
/var/lib/jenkins.
2. Create a Compressed Backup
Usetar to archive and compress the entire Jenkins home directory, saving it under /tmp with a timestamped filename:
- Recursively package
jenkins/. - Compress the archive (
.tar.gz). - Name it with the current date and time (e.g.,
202502070714).
Using a timestamp in your backup filename (e.g.,
$(date +"%Y%m%d%H%M")) makes tracking and rotating archives much easier.3. Verify the Backup Archive
After thetar command completes, confirm the archive exists and check its size:
4. Prepare a Test Environment
To validate the integrity of your backup without impacting production, create a sandbox copy:- Stop the Jenkins service to avoid data changes during copy.
- Copy the home directory to
/tmp/jenkins-backup. - Inspect the backup contents.
4.1 Stop Jenkins
Stopping the production Jenkins service may interrupt active builds. Perform this step during a maintenance window.
4.2 Extract or Copy
| Subdirectory | Contents |
|---|---|
| config.xml | Main Jenkins configuration file |
| jobs/ | Job definitions & build history |
| plugins/ | Installed plugins |
| secrets/ | Credentials and secret storage |
| users/ | User accounts and permissions |
| updates/ | Update-center metadata |
| workspace/ | Active build workspaces |
5. Point a Jenkins Instance at the Backup
Launch a standalone Jenkins instance using your sandboxed backup directory asJENKINS_HOME:
- Export the environment variable:
- Run the Jenkins WAR on a non-standard port (e.g., 9999):
- Monitor startup output:
6. Validate in the Browser
Open your browser and navigate to:- All your jobs are listed.
- Plugin manager shows installed plugins.
- Credentials, system configurations, and user accounts match production.