Posts Tagged duply
I’m moving my jenkins instance to a new server, which means meaning up & restoring it.
The nice thing about it is that it’s almost entirely self-contained in
/var/lib/jenkins, which means I really only have 1 directory to backup.
I’m using duply to back the folder up – but it’s 1.9GB in size. So to save space & bandwidth, I’m going to exclude certain files. This is the content of my
**/*.rpm **/plugins/*/ **/plugins/*.jpi **/plugins/*.bak **/workspace **/.jenkins/war
The main thing I’m excluding is the build artifacts – because I’m building RPMs, the SRPMS are rather large (nginx-pagespeed SRPMs weigh in at 110+MB), so I exclude all files ending in .rpm.
Next, I’m excluding most of the stuff in the plugin folder. My reasoning behind this is that the plugins themselves are downloadable. However, Jenkins disables plugins/pins plugins to the currently installed version by creating empty files of the form
<plugin>.jpi.pinned. I want these settings to carry over between versions. Unfortunately trying
+ **/plugins/*.jpi.pinned showed that everything else got removed from the backup. I’m assuming this is due to the use of an inclusive rule, so the default include got changed to default exclude.
In any case, I end up explicitly excluding things I don’t care about, which is probably good if something that I might need ever ends up in the plugins folder.
I also exclude workspace because everything can be recreated by building from specific git commits if need be. The job information is logged in
jobs/, so I can easily find past commits even though the workspace itself no longer exists.
Finally, I also exclude the jenkins war folder. I believe that this is an unpacked version of the .war file that gets installed to
/usr/lib/jenkins. It seems to get created when I start jenkins itself.
With just these 6 excludes, I’ve dropped the backup archive size down to <5 MB, which is a big win.
Normally I’d just take a live backup while Jenkins is running, but in this case where I’m moving servers, I completely shutdown Jenkins first, before taking a final backup with
duply jenkins full.
For the restore, I first installed Jenkins using a Jenkins playbook from Ansible Galaxy. It’s fairly barebones, but it works well – and I don’t need to spend time developing my own playbook. I also installed duply, and I manually installed an updated version of duplicity for CentOS 7 from koji to get the latest fixes.
Once I got duply set back up, I restored all the files to a new folder with
duply jenkins restore /root/jenkins. I restored it to a separate folder because duply appears to remove the entire destination folder if it exists, and I wanted to merge the two folders.
After the restore was complete, I ran
rsync -rtl --remove-source-files /tmp/jenkins/ /var/lib/jenkins to merge the restored data into the newly installed Jenkins instance.
At this point, everything should have worked, except I was unable to login. After spending some time fruitlessly searching Google, I ran
chown -R jenkins:jenkins /var/lib/jenkins, as the rsync didn’t preserve the file owner when it created the new files. Luckily enough, that fixed the problem, and I could now login.
I then spent a few hours working all this into an Ansible playbook so future moves are much easier.