<p>I'm using scripts from <a href="https://github.com/sue445/jenkins-backup-script" rel="noreferrer"><code>sue445/jenkins-backup-script</code></a>.</p>

<p>It archives Jenkins settings and plugins such as:</p>

<ul>
<li><code>$JENKINS_HOME/*.xml</code></li>
<li><code>$JENKINS_HOME/jobs/*/*.xml</code></li>
<li><code>$JENKINS_HOME/nodes/*</code></li>
<li><code>$JENKINS_HOME/plugins/*.jpi</code></li>
<li><code>$JENKINS_HOME/secrets/*</code></li>
<li><code>$JENKINS_HOME/users/*</code></li>
</ul>

<h3>Usage</h3>

<pre><code>./jenkins-backup.sh /path/to/jenkins_home archive.tar.gz

# add timestamp suffix
./jenkins-backup.sh /path/to/jenkins_home backup_`date +"%Y%m%d%H%M%S"`.tar.gz
</code></pre>

CC BY-SA 4.0
2018-09-06T06:06:33.760Z
2018-09-06T10:28:05.860Z
2018-09-06T10:28:05.860Z
nickcheng
<p>There are few ways to backup jenkins data and master configurations. The best way for backup is to use the <a href="https://plugins.jenkins.io/thinBackup/" rel="nofollow noreferrer">Thinbackup plugin</a>. You can schedule timely backups using cron expressions. You can configure full backup and incremental backup as well.</p>
<p>Another way to backup data and config is to take the disk snapshot of your jenkins master server. The ideal way to do this by mounting a disk and link the jenkins config directory to the disk mount point</p>
<p>Both the scenarios are well explained in this <a href="https://devopscube.com/jenkins-backup-data-configurations" rel="nofollow noreferrer">blog post</a>. You will get a better idea and steps for the configurations.</p>

CC BY-SA 4.0
2017-08-20T17:36:31.387Z
2021-11-12T05:30:48.070Z
2021-11-12T05:30:48.070Z
Bibin Wilson
<p>You can try the <a href="https://plugins.jenkins.io/thinBackup/" rel="nofollow noreferrer">thinBackup</a> plugin (even though it is not actively maintained) [if taking a <em>logical</em> backup is all you want] (i.e. most of the config xml files, jobs, nodes etc). The backup size won't be huge.</p>

CC BY-SA 4.0
2019-02-04T12:28:45.347Z
2021-10-30T05:43:39.467Z
2021-10-30T05:43:39.467Z
Saikat
<p>I needed to migrate a Jenkins from one Windows Server instance to another. Finally I managed to do it like that:</p>

<ul>
<li>Stop the Jenkins service (if you can afford it)</li>
<li>Copy the entire Jenkins folder (by default <code>C:\Program Files x86\Jenkins</code>)</li>
<li>Paste onto the new instance</li>
<li>Go inside the directory and run <code>jenkins.exe install</code></li>
</ul>

<p>This will register the freshly pasted Jenkins as a service on the new machine and will work 100% the same.</p>

<p>If this works then if you need a backup just for future safety, copy the Jenkins folder somewhere. It will work like a snapshot.</p>

CC BY-SA 4.0
2019-09-03T08:01:37.207Z
2019-09-03T08:01:37.207Z
mandarin
<p>All jobs (<code>jobs/</code>) and master config files (<code>config.xml</code>) can be found in <a href="https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins" rel="noreferrer">Jenkins home folder</a> (<code>JENKINS_HOME </code>) in the following structure:</p>
<pre><code>JENKINS_HOME
 +- config.xml     (jenkins root configuration)
 +- *.xml          (other site-wide configuration files)
 +- userContent    (files in this directory will be served under your http://server/userContent/)
 +- fingerprints   (stores fingerprint records)
 +- plugins        (stores plugins)
 +- workspace (working directory for the version control system)
     +- [JOBNAME] (sub directory for each job)
 +- jobs
     +- [JOBNAME]      (sub directory for each job)
         +- config.xml     (job configuration file)
         +- latest         (symbolic link to the last successful build)
         +- builds
             +- [BUILD_ID]     (for each build)
                 +- build.xml      (build result summary)
                 +- log            (log file)
                 +- changelog.xml  (change log)
</code></pre>
<p>Most of the config are in XML format, so backing all <code>.xml</code> files should be enough.</p>
<blockquote>
<p>All the settings, build logs, artifact archives are stored under the JENKINS_HOME directory. Simply archive this directory to make a back up. Similarly, restoring the data is just replacing the contents of the JENKINS_HOME directory from a back up.</p>
<p>Back ups can be taken without stopping the server, but when you restore, please do stop the server.</p>
</blockquote>
<hr />
<p>For consistent backups it is good practise to keep <code>JENKINS_HOME</code> directory under Git repository.</p>
<p>For example:</p>
<pre><code>cd $JENKINS_HOME
git init
shopt -s globstar
git add **/config.xml
git commit -m'Added job config files' -a
</code></pre>
<p>and pushing the files to the external repository. You can also add the following <a href="https://stackoverflow.com/a/38297609/55075"><code>.gitignore</code> file</a> to ignore some files.</p>
<p>Related: <a href="https://stackoverflow.com/q/2087142/55075">Is there a way to keep Hudson / Jenkins configuration files in source control?</a></p>

CC BY-SA 3.0
2018-04-26T22:16:11.657Z
How often do you create a backup? Do you push the code automatically to a git repository? If true, do you create a Pull Request that has to be merged manually (manual intervention) to do some backup integrity check?
030
CC BY-SA 3.0
2018-04-26T22:19:23.757Z
@030 Usually manually after some major changes, when I know the config is stable and I need to backup it, as Jenkins often likes to break things, such as changing slaves from unix to windows by it-self, removing passwords from forms, so having them in git/GitHub, I can easily compare and find the missing data and add it back or revert some specific file. There are some plugins to keep history changes, but I didn't find it useful.
kenorb
CC BY-SA 3.0
2018-04-26T22:23:16.913Z
You store the passwords in git? Do you encrypt them? Do you use pipelines aka Pipeline as Code as well?
030
CC BY-SA 3.0
2018-04-26T22:24:51.750Z
@030 Jenkins encrypts passwords/credentials by default, but you can easily [decrypt](https://devops.stackexchange.com/q/2191/3) them. However, without the master key (which should be not part of the backup) or access to Jenkins, nobody else can. I'm not using Pipeline as Code.
kenorb
CC BY-SA 3.0
2018-04-26T22:27:17.010Z
How do you test the integrity of this backup in git? E.g. do you spin up a virtual machine or docker system, mount the git repo and check whether everything still works?
030
CC BY-SA 3.0
2018-04-26T22:31:41.700Z
@030 Once I wanted to move Jenkins to another box, so I've cloned all `.xml` from git repo into new Jenkins folder (especially jobs), then I've hit the option in Jenkins to re-load the configs from file, and all jobs were imported fine. But it's a matter of trial and error or your goals which files you want to keep in git. Some of them are annoyingly changes too often.
kenorb
CC BY-SA 3.0
2017-03-18T13:42:12.890Z
2017-03-18T13:42:12.890Z
2020-06-18T08:28:10.803Z
kenorb
<p>If your Jenkins jobs are defined in a Jenkinsfile you can store it in a git repository and have it loaded up by using <a href="https://jenkins.io/doc/book/pipeline/jenkinsfile/" rel="noreferrer">Pipeline</a>.</p>

<p>Unfortunately, since not all Jenkins plugins support Jenkinsfile and Pipeline, you will need to manually create new Jenkinsfiles if you wish to move existing jobs to this format.</p>

CC BY-SA 4.0
2021-10-29T23:37:12.967Z
Re "_you will need to manually create_": There's the [Convert To Pipeline plugin](https://plugins.jenkins.io/convert-to-pipeline/). Though it doesn't work for all kinds of projects/configurations, it's worth to give it a try first.
Gerold Broser
CC BY-SA 4.0
2024-05-23T00:49:05.333Z
Yes, but there is additional configuration on top of that that is just stored in .xml config files, such as the repo url to find the jenkinsfile, log rotation, triggers, branch properties, etc.
cowlinator
CC BY-SA 3.0
2017-02-28T17:24:34.003Z
2017-02-28T17:24:34.003Z
avi
<p>The <a href="https://plugins.jenkins.io/scm-sync-configuration/" rel="nofollow noreferrer">SCM Sync Configuration Plugin</a> does exactly what you wish. Works with either svn or git to backup your jenkins core and job configuration, so gives you easy tracking as to who made changes, as well as a backup.</p>

CC BY-SA 3.0
2017-04-14T21:18:13.090Z
I literally tar the $JENKINS_HOME folder, but this seems soooo much better.
MrMesees
CC BY-SA 3.0
2017-10-23T09:35:06.063Z
That plugins seems pretty inactive/dead - is it really functional and on-par as of 2017?
Tuukka Mustonen
CC BY-SA 4.0
2021-10-29T23:42:50.983Z
The [SCM Sync Configuration plugin](https://plugins.jenkins.io/scm-sync-configuration/) is deprecated: "_In general, this means that this plugin is either obsolete, no longer being developed, or may no longer work._".
Gerold Broser
CC BY-SA 4.0
2017-03-21T19:59:45.617Z
2021-11-12T05:30:35.443Z
2021-11-12T05:30:35.443Z
Adam Berry
<p>I summarized how to <a href="https://www.rokpoto.com/backup-jenkins-file-system-snapshots/" rel="nofollow noreferrer">backup Jenkins using file system snapshots</a> and find this method the most effective and secure.</p>

CC BY-SA 4.0
2022-12-02T20:01:47.450Z
2022-12-02T20:01:47.450Z
rokpoto.com
<p>There are many ways to do this but the easiest way I can think of is doing a backup of the Jenkins home folder.</p>
<p>You can see where your Jenkins home folder is located with:</p>
<pre><code>su jenkins
echo $JENKINS_HOME
</code></pre>
<p>And for example, if you only want to backup the jobs you can go to:</p>
<pre><code>cd $JENKINS_HOME/jobs
</code></pre>
<p>And make a backup of that folder.</p>
<p>The configuration files are stored as a bunch of XML files.</p>
<p>If you are using the <a href="https://hub.docker.com/_/jenkins/" rel="nofollow noreferrer">official Jenkins docker image</a>, the home will be at <code>/var/jenkins_home</code>.</p>

CC BY-SA 3.0
2017-09-25T18:00:39.653Z
I needed to switch to the jenkins user to have access to the `$JENKINS_HOME` environment variable: `sudo su -s /bin/bash jenkins`, and then `echo $JENKINS_HOME`, which for me was `/var/lib/jenkins`
Bryce Guinta
CC BY-SA 3.0
2017-10-22T08:56:12.167Z
The problem with backing up the whole folder 'jobs' is that also the job executions will be copied - this may mean many GB.
Mike Argyriou
CC BY-SA 4.0
2018-05-04T15:35:03.633Z
Whether the service of Jenkins should restart?
Xin Meng
CC BY-SA 4.0
2019-04-13T14:16:31.207Z
Jenkins home in MacOS (Homebrew default installation): ~/.jenkins
chuckSaldana
CC BY-SA 4.0
2020-12-04T20:35:17.257Z
@MikeArgyriou `jobs/` contains just jobs configs and artifacts. Jobs executions is located in `workspace/`.
Alex Che
CC BY-SA 4.0
2020-12-04T20:41:09.047Z
So, to make a backup you need to first stop Jenkins process and then restart it, don't you? It would be nice if that could be done automatically from Jenkins by schedule, w/o the need to stop it.
Alex Che
CC BY-SA 4.0
2021-08-16T13:06:26.810Z
https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins has a Backup/Restore section, let me quote it:

`Back up and restore
All the settings, build logs, artifact archives are stored under the JENKINS_HOME directory. Simply archive this directory to make a back up. Similarly, restoring the data is just replacing the contents of the JENKINS_HOME directory from a back up.

Back ups can be taken without stopping the server, but when you restore, please do stop the server.`
coz
CC BY-SA 4.0
2017-02-28T17:15:06.537Z
2024-05-09T07:36:39.290Z
2024-05-09T07:36:39.290Z
Gepser Hoil
<p>I'd like to backup all Jenkins jobs and config files. What's the easiest way of doing it?</p>

CC BY-SA 3.0
2018-04-26T22:12:14.267Z
What did you try?
030
CC BY-SA 3.0
2018-04-26T22:13:21.890Z
I tried [this](https://devops.stackexchange.com/a/563/3).
kenorb
<jenkins><backup><linux>
How do you back up Jenkins jobs & master configs?
kenorb
# How do you back up Jenkins jobs & master configs?

(Asked by: username_0 on 2017-02-28)

I'd like to backup all Jenkins jobs and config files. What's the easiest way of doing it?

**Tags:** jenkins, backup, linux

> **Comments:**
> **username_1**: What did you try?  
> **username_0**: I tried [this](https://devops.stackexchange.com/a/563/3).  

---

## 9 answers

### Answer by username_13 on 2017-02-28. Score: 48 | Accepted answer

There are many ways to do this but the easiest way I can think of is doing a backup of the Jenkins home folder.
You can see where your Jenkins home folder is located with:
su jenkins
echo $JENKINS_HOME

And for example, if you only want to backup the jobs you can go to:
cd $JENKINS_HOME/jobs

And make a backup of that folder.
The configuration files are stored as a bunch of XML files.
If you are using the official Jenkins docker image, the home will be at /var/jenkins_home.

> **Comments:**
> **username_14**: I needed to switch to the jenkins user to have access to the `$JENKINS_HOME` environment variable: `sudo su -s /bin/bash jenkins`, and then `echo $JENKINS_HOME`, which for me was `/var/lib/jenkins`  
> **username_15**: The problem with backing up the whole folder 'jobs' is that also the job executions will be copied - this may mean many GB.  
> **username_16**: Whether the service of Jenkins should restart?  
> **username_17**: Jenkins home in MacOS (Homebrew default installation): ~/.jenkins  
> **username_18**: @MikeArgyriou `jobs/` contains just jobs configs and artifacts. Jobs executions is located in `workspace/`.  
> **username_18**: So, to make a backup you need to first stop Jenkins process and then restart it, don't you? It would be nice if that could be done automatically from Jenkins by schedule, w/o the need to stop it.  
> **username_19**: https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins has a Backup/Restore section, let me quote it:  `Back up and restore All the settings, build logs, artifact archives are stored under the JENKINS_HOME directory. Simply archive this directory to make a back up. Similarly, restoring the data is just replacing the contents of the JENKINS_HOME directory from a back up.  Back ups can be taken without stopping the server, but when you restore, please do stop the server.`  

---

### Answer by username_0 on 2017-03-18. Score: 40

All jobs (jobs/) and master config files (config.xml) can be found in Jenkins home folder (JENKINS_HOME ) in the following structure:
JENKINS_HOME
 +- config.xml     (jenkins root configuration)
 +- *.xml          (other site-wide configuration files)
 +- userContent    (files in this directory will be served under your http://server/userContent/)
 +- fingerprints   (stores fingerprint records)
 +- plugins        (stores plugins)
 +- workspace (working directory for the version control system)
     +- [JOBNAME] (sub directory for each job)
 +- jobs
     +- [JOBNAME]      (sub directory for each job)
         +- config.xml     (job configuration file)
         +- latest         (symbolic link to the last successful build)
         +- builds
             +- [BUILD_ID]     (for each build)
                 +- build.xml      (build result summary)
                 +- log            (log file)
                 +- changelog.xml  (change log)

Most of the config are in XML format, so backing all .xml files should be enough.

All the settings, build logs, artifact archives are stored under the JENKINS_HOME directory. Simply archive this directory to make a back up. Similarly, restoring the data is just replacing the contents of the JENKINS_HOME directory from a back up.
Back ups can be taken without stopping the server, but when you restore, please do stop the server.


For consistent backups it is good practise to keep JENKINS_HOME directory under Git repository.
For example:
cd $JENKINS_HOME
git init
shopt -s globstar
git add **/config.xml
git commit -m'Added job config files' -a

and pushing the files to the external repository. You can also add the following .gitignore file to ignore some files.
Related: Is there a way to keep Hudson / Jenkins configuration files in source control?

> **Comments:**
> **username_1**: How often do you create a backup? Do you push the code automatically to a git repository? If true, do you create a Pull Request that has to be merged manually (manual intervention) to do some backup integrity check?  
> **username_0**: @username_1 Usually manually after some major changes, when I know the config is stable and I need to backup it, as Jenkins often likes to break things, such as changing slaves from unix to windows by it-self, removing passwords from forms, so husername_6ng them in git/GitHub, I can easily compare and find the missing data and add it back or revert some specific file. There are some plugins to keep history changes, but I didn't find it useful.  
> **username_1**: You store the passwords in git? Do you encrypt them? Do you use pipelines aka Pipeline as Code as well?  
> **username_0**: @username_1 Jenkins encrypts passwords/credentials by default, but you can easily [decrypt](https://devops.stackexchange.com/q/2191/3) them. However, without the master key (which should be not part of the backup) or access to Jenkins, nobody else can. I'm not using Pipeline as Code.  
> **username_1**: How do you test the integrity of this backup in git? E.g. do you spin up a virtual machine or docker system, mount the git repo and check whether everything still works?  
> **username_0**: @username_1 Once I wanted to move Jenkins to another box, so I've cloned all `.xml` from git repo into new Jenkins folder (especially jobs), then I've hit the option in Jenkins to re-load the configs from file, and all jobs were imported fine. But it's a matter of trial and error or your goals which files you want to keep in git. Some of them are annoyingly changes too often.  

---

### Answer by username_6 on 2017-02-28. Score: 11

If your Jenkins jobs are defined in a Jenkinsfile you can store it in a git repository and have it loaded up by using [Pipeline](https://jenkins.io/doc/book/pipeline/jenkinsfile/).

Unfortunately, since not all Jenkins plugins support Jenkinsfile and Pipeline, you will need to manually create new Jenkinsfiles if you wish to move existing jobs to this format.

> **Comments:**
> **username_7**: Re "_you will need to manually create_": There's the [Convert To Pipeline plugin](https://plugins.jenkins.io/convert-to-pipeline/). Though it doesn't work for all kinds of projects/configurations, it's worth to give it a try first.  
> **username_8**: Yes, but there is additional configuration on top of that that is just stored in .xml config files, such as the repo url to find the jenkinsfile, log rotation, triggers, branch properties, etc.  

---

### Answer by username_9 on 2017-03-21. Score: 9

The [SCM Sync Configuration Plugin](https://plugins.jenkins.io/scm-sync-configuration/) does exactly what you wish. Works with either svn or git to backup your jenkins core and job configuration, so gives you easy tracking as to who made changes, as well as a backup.

> **Comments:**
> **username_10**: I literally tar the $JENKINS_HOME folder, but this seems soooo much better.  
> **username_11**: That plugins seems pretty inactive/dead - is it really functional and on-par as of 2017?  
> **username_7**: The [SCM Sync Configuration plugin](https://plugins.jenkins.io/scm-sync-configuration/) is deprecated: "_In general, this means that this plugin is either obsolete, no longer being developed, or may no longer work._".  

---

### Answer by username_2 on 2018-09-06. Score: 6

I'm using scripts from sue445/jenkins-backup-script.
It archives Jenkins settings and plugins such as:

$JENKINS_HOME/*.xml
$JENKINS_HOME/jobs/*/*.xml
$JENKINS_HOME/nodes/*
$JENKINS_HOME/plugins/*.jpi
$JENKINS_HOME/secrets/*
$JENKINS_HOME/users/*

Usage
./jenkins-backup.sh /path/to/jenkins_home archive.tar.gz

# add timestamp suffix
./jenkins-backup.sh /path/to/jenkins_home backup_`date +"%Y%m%d%H%M%S"`.tar.gz


---

### Answer by username_3 on 2017-08-20. Score: 6

There are few ways to backup jenkins data and master configurations. The best way for backup is to use the [Thinbackup plugin](https://plugins.jenkins.io/thinBackup/). You can schedule timely backups using cron expressions. You can configure full backup and incremental backup as well.

Another way to backup data and config is to take the disk snapshot of your jenkins master server. The ideal way to do this by mounting a disk and link the jenkins config directory to the disk mount point

Both the scenarios are well explained in this [blog post](https://devopscube.com/jenkins-backup-data-configurations). You will get a better idea and steps for the configurations.


---

### Answer by username_4 on 2019-02-04. Score: 4

You can try the [thinBackup](https://plugins.jenkins.io/thinBackup/) plugin (even though it is not actively maintained) [if taking a *logical* backup is all you want] (i.e. most of the config xml files, jobs, nodes etc). The backup size won't be huge.


---

### Answer by username_5 on 2019-09-03. Score: 2

I needed to migrate a Jenkins from one Windows Server instance to another. Finally I managed to do it like that:

* Stop the Jenkins service (if you can afford it)
* Copy the entire Jenkins folder (by default `C:\Program Files x86\Jenkins`)
* Paste onto the new instance
* Go inside the directory and run `jenkins.exe install`

This will register the freshly pasted Jenkins as a service on the new machine and will work 100% the same.

If this works then if you need a backup just for future safety, copy the Jenkins folder somewhere. It will work like a snapshot.


---

### Answer by username_12 on 2022-12-02. Score: 0

I summarized how to [backup Jenkins using file system snapshots](https://www.username_12/backup-jenkins-file-system-snapshots/) and find this method the most effective and secure.


---

