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?
I mean the whole settings:
The whole settings at once or maybe even as single backup/restore processes like e.g. MozBackup with its "Components selection"
or eclipse with its "Export Preferences" dialog
Create a project on JenkinsEnter function-export-example as name, select Pipeline , and click OK . In the newly created project, click Configure to set up. In the Pipeline section, select Pipeline script from SCM as Definition , Git as SCM , and your repo url as Repository URL . Click Save at the bottom.
According to the manual, https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins, it's simply to move the corresponding job directory to the new Jenkins instance. The "Copy existing Job" option requires the job to exist on the current Jenkins instance. It's an option to use the existing job as a template.
There is no simple way to backup/export selected parts of the configuration, since Jenkins configuration data is scattered among
config.xml
, lots of plugin-specific files)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., as of version 1.7.4, thinBackup
does not backup Jenkins' secret keys, so it's impossible to restore credentials from scratch.
Maybe thinBackup plugin will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With