So I had a FreeBSD jail today running a geriatric version of MySQL that was long past time to update. But sometimes when you perform big updates you discover problems along the way, and it takes much longer than usual. This particular jail can’t tolerate a lot of downtime so I thought it would be nice to perform a “practice” upgrade to flush out all of the problems and have solutions ready when I’m ready to perform the live upgrade. My idea was to clone the jail and perform a practice upgrade on that. It was easy.
First, clone the file system. That’s easy because I keep all of my jails on their own ZFS file systems and maintain daily snapshots:
zfs clone firstname.lastname@example.org zroot/jails/vhost2upgrade
And of course that happens pretty much instantly.
Next I found a free IP address on the server, created a new jail and started it up:
ezjail-admin create -x vhost2upgrade 10.0.0.42
ezjail-admin start vhost2upgrade
ezjail-admin console vhost2upgrade
Now I’m logged into a clone of my server jail and I can perform my MySQL upgrade and figure out all the little details before I perform it on the live server jail.
All done? Clean up after yourself. Log out of the jail and then from the host system:
ezjail-admin stop vhost2upgrade
ezjail-admin delete vhost2upgrade
zfs destroy zroot/jails/vhost2upgrade
An even better setup would be if I had set up my jail with server and user data on separate partitions. Then, once I had the server data working the way I wanted, I could
zfs promote the clone’s server partition. To do.