To protect data residing on my Synology NAS I’ve bought and installed an UPS, an APC 700U to be exact. The trigger for buying and installing one was the loss of (some) disk data event that happened to family member external hard disk due to power loss. The data recovery cost was higher than buying an UPS and of course the lack of backups added to outcome of that event.
While no Synology NAS was involved on the above data loss, I know first hand that backups by themselves only add one layer of protection to possible data loss, and since from time to time I also have some power loss events, it was just a matter of time that my NAS might be hit by an unrecoverable power event, and, who knows, data loss.
So buying an UPS just might be a good idea…
Anyway the UPS from APC that I bought has an USB port allowing it to be connected to the Synology, which allows the UPS to be monitored and also allows the NAS to gracefully shutdown before UPS battery exhaustion. As a bonus it also allows to run an UPS monitoring server where other devices that share the same UPS power source can be notified of a power event through the network. Just keep in mind that the network switch or router must also be power protected…
Installing the UPS:
Installing the UPS is as simple as power down all devices that will connect to the UPS: Synology NAS, Odroid, external hard disks, PC base unit and network switch, and connecting an USB cable from the UPS to the back Diskstation USB ports.
After starting up, just go to DSM Control Panel and select Hardware & Power and then the UPS tab. Enable the UPS by ticking the Enable UPS support and also enable the UPS server to allow remote clients by ticking Enable UPS Network Server:
We can see by pressing the Device Information button that the UPS was correctly detected:
To end the configuration we need to press the Permitted DiskStation Devices and add the IP’s address of the devices that also have their power sources connected to the UPS and will also monitor the power status, in my case the IP of Odroid and my home PC.
And that’s it.
Setting up Arch Linux
Interestingly I dind’t found the NUT tools (Network UPS tools) on the core Arch repositories, but they are available at the AUR repository:
yaourt -S network-ups-tools nut-monitor
The above packages will install the core NUT tools and a graphical monitor.
We can now scan our network for the ups:
nut-scanner -s 192.168.1.16
Scanning USB bus.
Scanning SNMP bus.
Scanning XML/HTTP bus.
Scanning NUT bus (old connect method).
driver = "nutclient"
port = "email@example.com"
With the UPS reference found, we can now query it:
Init SSL without certificate database
device.mfr: American Power Conversion
device.model: Back-UPS XS 700U
We can check the load, for example, with:
upsc firstname.lastname@example.org | grep load
Init SSL without certificate database
We need now to modify the following files on /etc/ups:
First, as root, we copy a file from upsmon.conf.sample to upsmon.conf and add the following line:
MONITOR email@example.com 1 * * slave
after the other commented out MONITOR lines. Since I’m only monitory, I’ve just put * at the username and password for authentication.
On nut.conf, we change the line MODE to MODE=netclient
After changing the files, we enable and start the UPS monitoring service:
sudo systemctl enable nut-monitor
sudo systemctl start nut-monitor
We are now monitoring the UPS status through the network. Keep in mind that the hub/switch power should also be connected to the UPS.
For monitoring we can use the nut-monitor application to see the UPS status in a nicer way:
To make the application easier to use, we can create a profile and save it, and when calling the application nut-monitor, we pass the profile name with the -F switch.
Setting up Odroid
To allow Odroid to monitor the UPS status through the Synology UPS server we need to also install the nut UPS tools (the same used by Arch Linux and DSM):
apt-get install nut
The configuration steps for Odroid are the same as the Arch Linux steps, but since Odroid is running an Ubuntu variant, the files are located on a different path: /etc/nut.
To start the monitoring with the new configuration we just do /etc/init.d/ups-monitor restart.
If authentication is needed, on the Synology disk, check the NUT configuration files located at /usr/syno/etc/ups/.
The upsd.users file has the user and password defined by default by the NUT tools on DSM.