DEV Community

Cover image for Patch Proxmox Containers Safely with Snapshots
Mike Maiolo | Pontavia Consulting
Mike Maiolo | Pontavia Consulting

Posted on Edited on Originally published at pontaviaconsulting.com AI-assisted

Patch Proxmox Containers Safely with Snapshots

Key takeaways

  • Check the app works first, snapshot, patch, check again, and roll back if the second check fails.
  • Use pct snapshot, pct rollback and pct delsnapshot; they need snapshot-capable storage.
  • A rollback loses everything written inside the container since the snapshot, so databases need their own backups.
  • Some updates only take effect after a restart, so check again after a reboot if you allow one.

The idea in four steps

  1. Check that the app works before you touch it. Never patch something that is already failing.
  2. Take a snapshot so there is a way back.
  3. Run the updates.
  4. Check again. If the app still answers, keep going. If it does not, roll back to the snapshot.

What you need

  • A Debian or Ubuntu container. The commands below use ID 105.
  • Storage that supports snapshots for that container (for example ZFS, LVM-thin or Ceph).
  • One check that proves the app works, such as a health URL.

Step by step

1. Check it works now.

curl -fsS https://app.example.com/health
Enter fullscreen mode Exit fullscreen mode

2. Take a snapshot and wait for it to finish:

pct snapshot 105 pre-patch --description "before apt upgrade"
Enter fullscreen mode Exit fullscreen mode

3. Run the updates inside the container:

pct exec 105 -- bash -c 'apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade'
Enter fullscreen mode Exit fullscreen mode

4. Check again, giving services a few seconds to restart:

sleep 30
curl -fsS https://app.example.com/health
Enter fullscreen mode Exit fullscreen mode

5a. It works. Keep the snapshot for a few days as a rollback point, then delete it:

pct delsnapshot 105 pre-patch
Enter fullscreen mode Exit fullscreen mode

5b. It does not. Stop the container, roll back, and start it again:

pct stop 105
pct rollback 105 pre-patch
pct start 105
Enter fullscreen mode Exit fullscreen mode

Limits you should know about

  • A rollback loses what was written since the snapshot. That includes database rows, uploaded files and logs. For databases, rely on their own backups, not on snapshots alone.
  • Some updates need a restart. A library update can take effect only after the service or the container restarts, so a check straight after the upgrade may not show the problem. Reboot, if you allow it, and check a second time.
  • Do not stack old snapshots. Delete only the ones you created, and only after the check passed.
  • Virtual machines use the same idea with qm snapshot, qm rollback and qm delsnapshot, and you run the updates over SSH or the guest agent. See the qm manual.

Making it a monthly habit

The manual version is easy to skip. Pontavia's Proxmox Safe Patch ($59) is an n8n workflow that does exactly this. It checks your app answers, takes a snapshot, runs apt upgrade inside the guest, then checks again. If the app still works, the snapshot stays as a rollback point and older ones are cleaned up. If it broke, the guest is rolled back, started again, and you get an alert saying what failed.

It starts in report-only (dry run) mode, never patches a guest that is already failing a check, and never installs without a finished snapshot. It only deletes snapshots it made itself, and reboots only if you allow it. It was tested on Debian 12 and Ubuntu 24.04 containers, including a reboot. Virtual machines use the same steps but are not tested yet.

Frequently asked questions

Can I take a snapshot of a running Proxmox container?

Yes, on storage that supports snapshots. pct snapshot works on a running container. If your storage does not support snapshots, take a vzdump backup before patching instead.

What if my storage does not support snapshots?

Then pct snapshot will fail. Take a vzdump backup before patching and restore it if the update breaks something. It is slower but gives you the same safety net.

Should I use apt-get upgrade or dist-upgrade?

For routine patching, apt-get upgrade is the conservative choice because it does not remove packages or add new ones. dist-upgrade can change the package set and is better kept for planned upgrades.

Is this how I should patch the Proxmox host itself?

No. Host updates and reboots are a separate procedure. See the guide on finding Proxmox nodes that need updates or a reboot.


Originally published at pontaviaconsulting.com. More guides like this: https://pontaviaconsulting.com/guides.html.

Top comments (0)