Here’s a few examples, all run from $JENKINS_HOME/jobs

#!/bin/bash

export JENKINS_HOME=/opt/jenkins

cd $JENKINS_HOME/jobs

#
# Copy directory and config.xml to /tmp
#
find . -name config.xml -exec ls {} \; | while read dir_file
do
   cp --parents $dir_file /tmp
done

#
# tar up directories and config.xml
#
find . -name config.xml -exec ls {} \; | xargs tar cvf backup.tar

#
# Copy directories and config.xml only to remote server
#
find . -name config.xml -exec ls {} \; | xargs tar cf - | ssh user@remotehost 
"cd /jenkins_home/jobs;tar xvf -"

--
Adam vonNieda
[email protected]




> On Jan 11, 2019, at 4:02 PM, RAJENDRA PRASAD <[email protected]> 
> wrote:
> 
> Hi all,
> I am trying to implement Jenkins jobs backup on existing Jenkins instance and 
> restore on new jenkins server mechanism.
> 
> For that I need to copy/backup all the jobs from each jenkins instance .
> 
> I am using Linux OS and I need to use shell command for that.
> 
> Can anybody help me in with shell command that can only copy job folder name 
> and its config.xml file alone for each job recursively.
> 
> Thanks,
> Rajendra
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/CAMrg02RZiNdom2ZQBeOjN5iqgBm2jV3L00mU7279KghF17YU4Q%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/CAMrg02RZiNdom2ZQBeOjN5iqgBm2jV3L00mU7279KghF17YU4Q%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/B139107B-51D3-444C-A919-8661BCEC99A8%40vonnieda.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to