These days, my work seems more like archeology than implementing newest and coolest web technologies, but someone has to keep an eye on old web servers which are useful to people.
In this case, it's two major Debian releases upgrade which of course did result in some amount of breakage as you would expect. Most of breakage was easy to fix, but we had one site which had only pyc files, and python2.6 with correct modules wasn't supported on current distribution.
First idea was to use python de-compiler to generate source python files, and this only got me to different python errors which I didn't know how to fix. so, this was dead end.
I did have a backup of machine before upgrade on zfs pool, so next logical idea was to run minimal amount of old binaries to keep the site up. And I decided to do it in chroot so I can easily share mysql socket from current installation into pre-upgrade squeeze. Let's see what was involved in making this happen.
1. make writable copy of filesystem
Our backups are on zfs pool, so we cloned all three disks into same layout as they are mounted on filesystem:
2018-06-08.10:07:53 zfs clone lib15/backup/pauk.ffzg.hr/0@2018-05-01 lib15/export/pauk.ffzg.hr 2018-06-08.10:08:19 zfs clone lib15/backup/pauk.ffzg.hr/1@2018-05-01 lib15/export/pauk.ffzg.hr/home 2018-06-08.10:08:38 zfs clone lib15/backup/pauk.ffzg.hr/2@2018-05-01 lib15/export/pauk.ffzg.hr/srv
2. nfs export it to upgraded server
Take a note of crossmnt parameter, this will allow us to mount all descending filesystems automatically.
root@lib15:~# grep pauk /etc/exports /lib15/export/pauk.ffzg.hr 10.21.0.2(rw,fsid=2,no_subtree_check,no_root_squash,crossmnt) root@lib15:~# exportfs -va exporting 10.21.0.2:/lib15/export/pauk.ffzg.hr
3. mount nfs export
root@pauk:~# grep squeeze /etc/fstab 10.21.0.215:/lib15/export/pauk.ffzg.hr /mnt/squeeze nfs defaults,rw 0 0
4. start chroot with old version of service
To make this work, I first edited apache configuration in chroot to start it on different port, and configured front-end server to redirect site to new port.
root@pauk:/home/dpavlin# cat chroot-squeeze.sh to=/mnt/squeeze mount --bind /dev $to/dev mount --bind /sys $to/sys mount --bind /proc $to/proc mount --bind /var/run/mysqld/ /mnt/squeeze/var/run/mysqld/ /usr/sbin/chroot $to /etc/init.d/apache2 start
5. redirect apache traffic to server in chroot
You will have to insert something like this in current apache configuration for vhost:
<Proxy http://127.0.0.1:18080/*> Order allow,deny Allow from all </Proxy> <Location /german2/> RequestHeader set Host "www.ffzg.unizg.hr" ProxyPreserveHost On ProxyPass http://127.0.0.1:18080/german/ ProxyPassReverse http://127.0.0.1:18080/german/ </Location>
You might scream at me that in days of containers, systemd and other better solutions chroot is obsolete. In my opinion, it's just a right tool for a job from time to time, if you have backup :-)