← Back to context

Comment by crossroadsguy

3 days ago

Hey, what's the trick of keeping your VPS OS/etc updated and upgraded without having to nuke (or replace or copy to elsewhere and "paste" back) the current setup on that VPS? In all my self hosting attempts it works butter smooth until I try to update/upgrade my VPS OS or hell even the app I am using like a VPN, or a seedbox, a notes app etc etc. I mean it's been really painful. Sometimes I have used the VPS w/o updating for 3-4 years - no security/OS update - none. The moment I do that - bam! Everything broken or gone :(

Two basic ways:

1) Use your VPS OS's native software upgrade mechanism

2) Build, test, and deploy immutable images

For 1), you configure your OS (Ubuntu LTS let's say) to do automatic unattended upgrades only for security updates (check documentation for instructions). They're designed to be backwards compatible so this is safe and automatic. May require you to periodically reboot the box. When that version of Ubuntu is eventually end-of-life, they usually provide a manual upgrade procedure to upgrade in-place to a newer version of Ubuntu. A couple manual steps over an hour or two and you're set until the new version goes EOL (many years for Ubuntu LTS).

For 2), you would build either a container or a disk image with your OS, preferred software, configs, etc. Build the image (Packer for disk image, Docker for container), write a simple test to run it and make sure it's working. Now you can install that new container or disk image onto your VPS, and you know it'll work. This is more work, but the resulting image is guaranteed to work the same way every time. So every time you upgrade, you just build a new image. If the new image doesn't work for some reason, just go back to the last image that did work. Set all this up on a CI/CD platform (GitHub Actions, CircleCI, etc) and you can just keep using that setup forever, no need to get it set up on your laptop again if you reinstall your laptop OS.

For either of these, it helps to use only software that is packaged for your OS, rather than installing custom software. There will be less extra work to perform to get the software to work and configured, and upgrade steps will be smoother.

For 2), it also helps to use a VPS which has a Terraform provider (https://registry.terraform.io/browse/providers?category=infr...) so you can write code to automate updating your VPS's disk image (or restoring an old one).