Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alpoza/738928ab9d7b9e58d9f61eeb4a775119 to your computer and use it in GitHub Desktop.
Save alpoza/738928ab9d7b9e58d9f61eeb4a775119 to your computer and use it in GitHub Desktop.
Moving Jenkins server configuration from one server to another
ORIGINAL_JENKINS_SERVER=
ORIGINAL_SERVER_USER=
NEW_JENKINS_SERVER=
NEW_SERVER_USER=
# ON THE ORIGINAL JENKINS SERVER
ssh $ORIGINAL_SERVER_USER@$ORIGINAL_JENKINS_SERVER
cd /var/lib/jenkins/
for i in `ls jobs`; do echo "jobs/$i/config.xml";done > config.totar
#find jobs -name config.xml > config.totar
#or
#tar zcf /tmp/jenkins_config.tar.gz *.xml userContent/ plugins/ jobs/*/config.xml
tar zcf /tmp/jenkins_config.tar.gz *.xml userContent/ plugins/ -T config.totar
exit
# ON YOUR WORKSTATION
scp $ORIGINAL_SERVER_USER@$ORIGINAL_JENKINS_SERVER:/tmp/jenkins_config.tar.gz .
scp jenkins_config.tar.gz $NEW_SERVER_USER@$NEW_JENKINS_SERVER:/tmp/
# ON THE NEW JENKINS SERVER
ssh $NEW_SERVER_USER@$NEW_JENKINS_SERVER
cd /var/lib/jenkins
sudo tar xvzf /tmp/jenkins_config.tar.gz
sudo chown -R jenkins:jenkins .
sudo vi config.xml
# Remove all the slaves
sudo service jenkins restart
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment