Update Proxmox and TrueNAS unattended overnight, in the right order
Write the whole window as one script on the Proxmox host and start it with a one-off timer. Check last night’s backup first, stop the guests that use the NAS, let TrueNAS update and come back, then upgrade and reboot Proxmox. On 7 November that ran at 04:30 with nobody awake: TrueNAS went from 25.04.2.3 to 25.04.2.6, Proxmox from 9.2.20 to 9.2.26 (85 packages and a new kernel), and all 12 guests were running again at 04:46.
The order
The NAS holds the backups and the storage for three guests, so it goes first, and Proxmox reboots last:
- 03:00: the nightly backup runs as usual. At 04:30 the script checks that it finished and every guest succeeded. On the night: 12 of 12, in 56 minutes.
- Check that the NAS’s NFS shares answer, then download the Proxmox packages without installing them.
- Shut down the guests whose disks or data sit on the NAS. For me that’s media, Immich and Frigate. An NFS mount doesn’t fail while the NAS is down; it hangs.
- Update TrueNAS. It was back at 04:38.
- Upgrade Proxmox and reboot. Every guest has
onboot: 1, so they all come back, and the NAS is already up when they do.
Any failed check in steps 1 to 3 stops the run with nothing changed. If TrueNAS isn’t answering within 30 minutes of step 4, the script stops without touching Proxmox, so a broken NAS doesn’t come back to a half-upgraded host.
The timer
systemd-run makes a timer that exists only until it fires or the host reboots. With the names changed, it looks like this:
systemd-run --on-calendar='2026-11-07 04:30' --unit=night-maint /root/night-maint.sh
systemctl list-timers night-maint.timer # check it's armed
systemctl stop night-maint.timer # cancel
The script writes its own log, and the apt output goes to a second one, so the morning check starts with tail on both.
Run apt in its own unit
apt-get full-upgrade runs in a separate unit, not as a child of the script, along these lines:
systemd-run --wait --unit=night-maint-apt \
-E DEBIAN_FRONTEND=noninteractive \
apt-get -y -o Dpkg::Options::=--force-confold full-upgrade
Two reasons. The upgrade includes ifupdown2, which can reload the network halfway. And the day before, on a VM, an upgrade started through qemu-guest-agent died when apt upgraded the guest agent itself and restarted it, taking apt down with it and leaving 34 packages unconfigured. dpkg --configure -a in its own unit fixed that, but a unit of its own avoids it.
Let TrueNAS update itself
I didn’t want a TrueNAS API key sitting on the Proxmox host. Instead, a one-off cron job on TrueNAS watches, during the night’s window, for a go file in a folder on the backup share, which Proxmox mounts over NFS. The script writes the file at step 4, and TrueNAS updates and reboots. When the NFS share answers again, TrueNAS is back.
TrueNAS runs cron in its own time zone, which on mine was still America/Los_Angeles, so the job’s window had to be 19:00 to 22:55 on the 6th for a 04:30 start in Paris on the 7th.
Rehearse it the evening before
A dry run of the same script, stopping before any change, checked the backup, the NFS shares and the package list (86 to install, none to remove), and that TrueNAS answered the go file. It also helps to know the way back before you need it:
/bootis on LVM here, so GRUB can’t do a “try the new kernel once” boot. If the new kernel fails, it’s a screen and keyboard, and the old kernel from GRUB’s Advanced options.- The firewall is a VM on the same host, so the internet is down for the ten minutes of the reboot.
- TrueNAS keeps the previous boot environment, so the update can be undone from System → Boot.
In the morning I checked that every guest was running, every Prometheus target was up, every NFS mount answered, no alert had fired overnight, and the Home Assistant heartbeat had never lapsed.