Workbench Notes

Clean shutdowns with NUT and a cheap UPS

· powernut

We had two short power cuts in November. The NAS survived both, but only because the outages were shorter than the battery. Time to make shutdowns automatic.

Setup

The UPS is an APC Back-UPS 700 connected over USB to the NAS, which runs the NUT server. The mini PC is a NUT client over the network.

apt install nut
# /etc/nut/ups.conf
[apc]
    driver = usbhid-ups
    port = auto
    desc = "Back-UPS 700"
# /etc/nut/nut.conf
MODE=netserver

On the NAS, upsc apc should now print battery charge and runtime. If it says driver not connected, unplug and replug the USB cable after installing — the udev rule only applies to new devices.

Shutdown order

The mini PC mounts shares from the NAS, so it has to go down first. NUT handles this with FINALDELAY on the primary and a normal client config on the secondary:

# /etc/nut/upsmon.conf on the mini PC
MONITOR apc@192.168.1.10 1 monuser CHANGE_ME secondary
SHUTDOWNCMD "/sbin/shutdown -h now"
# /etc/nut/upsmon.conf on the NAS
MONITOR apc@localhost 1 monuser CHANGE_ME primary
FINALDELAY 60

Testing

Pulling the plug is the real test. With about 40% load the UPS reported 14 minutes of runtime; NUT triggered on low battery, the mini PC shut down, the NAS followed a minute later, and both came back on their own once power returned (BIOS setting: restore on AC power loss).

Write the passwords in upsd.users before you test, not after the first failed login floods the log.