Migrating Jenkins to a new server
After getting annoyed with the outdated packages on CentOS 5.6 I decided to migrate my Jenkins server to Ubuntu 16.04.
It was surprisingly straightforward:
Backup the old Jenkins server in case something goes wrong.
Setup a new server with Ubuntu 16.04 (guide).
You can get $10 credit to run a server on DigitalOcean by using my referral link.Install Jenkins on the new server (guide):
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkinsSync the
/var/lib/jenkinsfolder on the old server to the new one by running this command from the new Jenkins server (where1.2.3.4is the old server’s IP anduseris the old server’s ssh user):rsync -av user@1.2.3.4:/var/lib/jenkins /var/lib --exclude workspace/ --exclude cache/ --exclude .cache/ --exclude node_modules/ --exclude .npm/I excluded some directories to speed up the process but thats up to you. Check out this guide for more on using
rsyncremotely.Restart Jenkins:
systemctl restart jenkinsDone!