Skip to content
article

UPS + NUT: auto shutdown 3 Proxmox node and the NAS when the power cut (rainy season guide)

Full config, the shutdown order, and the first test that went wrong

September 10, 2026 · 3 min read

Rainy season in HCMC. Some weeks we have 2-3 power cuts, 10 to 40 minutes. My APC Back-UPS 1000VA can run my 186W lab for ~18 minutes (UPS says), so for long cuts everything must shut down cleanly by itself, even when I am at work or asleep. This is how I do it with NUT (Network UPS Tools).

Plan

  • The UPS USB cable goes to one machine. That machine is the NUT primary (server)
  • All other machines are secondary (clients) and listen over the network
  • Rule: on battery for 3 minutes, OR battery low, then shut down everything
  • Order: VMs → Proxmox nodes → NAS last (the VMs keep disks on the NAS)

Primary (the box with the USB cable)

TrueNAS has NUT built in (System Settings, Services, UPS) and you can do all of this in the UI. On a normal Debian or Proxmox host it looks like this:

apt install nut

# /etc/nut/nut.conf
MODE=netserver

# /etc/nut/ups.conf
[apc]
    driver = usbhid-ups
    port = auto
    desc = "Back-UPS 1000"

# /etc/nut/upsd.conf
LISTEN 0.0.0.0 3493

# /etc/nut/upsd.users
[monuser]
    password = change-me-please
    upsmon primary

# /etc/nut/upsmon.conf
MONITOR apc@localhost 1 monuser change-me-please primary
SHUTDOWNCMD "/sbin/shutdown -h +0"

Check:

$ upsc apc@localhost
battery.charge: 100
battery.runtime: 1080
ups.load: 31
ups.status: OL

OL = online, OB = on battery, LB = low battery. battery.runtime is in seconds.

Secondaries (each Proxmox node)

# /etc/nut/nut.conf
MODE=netclient

# /etc/nut/upsmon.conf
MONITOR apc@192.168.10.5 1 monuser change-me-please secondary
SHUTDOWNCMD "/sbin/shutdown -h +0"

Proxmox already shut down the VMs when the host shut down (set a shutdown timeout per VM in the VM options, default can be too long).

The 3 minute timer: upssched

By default NUT only shut down at low battery. I want earlier, because my UPS battery is 3 years old and I don't trust its "18 minutes". In upsmon.conf on the primary add:

NOTIFYCMD /sbin/upssched
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC

/etc/nut/upssched.conf:

CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /run/nut/upssched.pipe
LOCKFN /run/nut/upssched.lock
AT ONBATT * START-TIMER onbatt 180
AT ONLINE * CANCEL-TIMER onbatt
AT LOWBATT * EXECUTE onbatt

/etc/nut/upssched-cmd (chmod +x):

#!/bin/sh
case $1 in
  onbatt) /sbin/upsmon -c fsd ;;
esac

upsmon -c fsd = "forced shutdown". The primary tells all secondaries to shut down, waits for them to disconnect, then shuts down itself.

First test failed

I pull the UPS plug from the wall (everything backed up first!). After 3 min, the NAS shut down in ~20 seconds, the Proxmox nodes were still shutting down VMs that have disks on the NFS share from the NAS. Two VMs had a bad time.

The reason: the primary waits for the secondaries to log out, but only for HOSTSYNC seconds (default 15). My nodes need ~2 minutes to stop all VMs. Fix in primary upsmon.conf:

HOSTSYNC 180

Also make sure your 3 minute timer + 3 minutes HOSTSYNC + shutdown time is less than the real battery runtime, with margin.

Coming back

In the BIOS of every machine: "Restore on AC power loss: Power On". Then when power come back, everything boot by itself. Put the NAS first in boot priority or add a delay to the Proxmox nodes, so NFS is ready before VMs start.

And replace the UPS battery every 3 years. Lead acid hate heat, and Saigon is heat.

hope this help :)

Written by

Nguyễn Minh Hiếu

Proxmox, Docker, ZFS, and a power bill my wife asks about. HCMC 🇻🇳 Backend dev by day, homelab by night. Founder of Self Hosted. Back up your data, seriously.

Get the best of #self_hosted weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.

Comments

8

Sign in to join the conversation.

Sign in to comment
Bikash Kalita@bikash_from_ghy#4 in Self Hosted
My UPS is basically a family member at this point, so I appreciate a post that treats it with respect
0 net votes
Graham Whitfield@greybeard_graham#2 in Self Hosted
Pulling the plug is the only test that counts. Everyone has a shutdown script. Very few have watched it run. The HOSTSYNC detail is the sort of thing you only learn by doing it. Cheers, G.
1 net votes
Lindiwe Mokoena@loadshedding_lindi#4 in Self Hosted
Ja, the HOSTSYNC thing got me too. In SA our cuts are 2 to 4 hours scheduled, so I went the other way: inverter + LiFePO4 for the whole rack and NUT only as the last resort. But this is the right guide for short random cuts
2 net votes
Oleksii Bondarenko@oleksii_kyiv2 rep in Self Hosted
One warning from Kyiv: a power station is not a UPS. My first one had ~30ms switchover and the router rebooted on every outage, twice per night sometimes. Get a real UPS or a power station with a true UPS mode, and test it with the plug like Hieu did.
2 net votes
Brett Hollister@brett_hsv#9 in Self Hosted
Solid writeup brother. I run NUT secondary on my OPNsense box too so the firewall goes down last-ish and comes up first. Also y'all, put the switch on the UPS, the secondaries can't hear the primary yell "shutdown" if the switch died first. my 2 cents
5 net votes
Nguyễn Minh Hiếu@homelab_hieu#1 in Self Hosted
the switch on UPS, yes! I learn this one in the first year also :D
1 net votes
Brody MacLeod@brody_yyc1 rep in Self Hosted
What UPS do people use for a NAS around 100W? Calgary, outages are rare but long when they happen.
2 net votes
Nguyễn Minh Hiếu@homelab_hieu#1 in Self Hosted
for ~100W any line-interactive 1000-1500VA with USB that NUT support (APC Back-UPS Pro, CyberPower CP1500 etc) is fine. check the NUT hardware compatibility list before you buy. for long outages UPS is only for clean shutdown, not to keep running :)
1 net votes