I'd like to backup all Jenkins jobs and config files. What's the easiest way of doing it?
There are many ways to do this but the easiest way I can think is doing a backup of the Jenkins Home folder.
You can see where is your Jenkins home with:
And for example, if you only want to backup the jobs you can go to:
And make a backup for that folder.
All that configuration will be a bunch of XML files.
If you are using the official Jenkins docker image, the home will be on:
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.
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.
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.
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.
The SCM Sync Configuration Plugin 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.
There are few ways to backup jenkins data and master configurations. The best way for backup is to use the Thinbackup plugin. 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. You will get a better idea and steps for the configurations.
I'm using scripts from
It archives Jenkins settings and plugins such as:
./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
You can try the 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.