How to export/import the Jenkins configuration?

The Jenkins CLI provides the function to export&import single jobs, e.g.:

java -jar jenkins-cli.jar -s http://foo-jenkins.tld:8080 get-job myjob > myjob.xml
java -jar jenkins-cli.jar -s http://bar-jenkins.tld:8080 create-job newmyjob < myjob.xml

Is it also possible / How to backup&restore the configs?

  • SVN repository backup strategies
  • Managing Git Users and Passwords
  • restoring a repository from a .git folder
  • including the .git folder when running git archive
  • Git: How to forget very old commits
  • Site Backup on Flash Drive with Git

  • I mean the whole settings:

    • the system configuration,
    • the global security configuration,
    • the credentials,
    • the global tool configuration,
    • the plugins configuration (the “HTTP Proxy Configuration” and the list of the installed plugins)
    • the nodes
    • the users
    • is anything missing?

    The whole settings at once or maybe even as single backup/restore processes like e.g. MozBackup with its “Components selection”

    MozBackup - Components selection

    or eclipse with its “Export Preferences” dialog

    eclipse - Export Preferences

  • How can I pass multiple config key-value pairs to git clone?
  • Is “git push --mirror” sufficient for backing up my repository?
  • GIT mirror with FTP
  • Trigger jenkins build on stash pull request
  • Alternatives to Git for Minecraft server backup/version control
  • Git More than one value for the key
  • 3 Solutions collect form web for “How to export/import the Jenkins configuration?”

    There is no simple way to backup/export selected parts of the configuration, since Jenkins configuration data is scattered among

    • several files (global config.xml, lots of plugin-specific files)
    • several sub-directories (credentials, nodes) and
    • some of the files are encrypted (credentials), so you must also backup the encryption keys

    The cleanest solution will be to back-up the entire $JENKINS_HOME, and to exclude those parts that you do not want to be part of the backup (e.g., exclude jobs/*/builds). With that you’ll end up with a resonable backup size also.

    Such a backup must be done on filesystem level, as there’s no API to access all those files/data.

    Do not rely on thinBackup, as you depend on the plugin maintainers to not miss anything important. E.g., current thinBackup version 1.7.4 will not backup Jenkins’ secret keys, so it’s impossible to restore credentials from scratch.

    The mentioned requirement can be easily achieved using the below plugin

    Below issues will be solved while using this plugin

    • Config changes are versioned
    • Config changes can be compared
    • Config changes can be reverted back

    Maybe thinBackup plugin will help you:

    Git Baby is a git and github fan, let's start git clone.