Shut down HA on Synology NAS

I have HA running in a Docker instance on DSM 7. The last time I shut down the NAS box I found on rebooting that the HA database was corrupt and I lost a lot of data.

What is the correct way of shutting down and restarting please?

You could try creating an automation that first shuts down HA followed by the NAS, but I’m not sure if it will proceed to shutting the NAS down once the command has been sent to shut down HA, or if there would be enough time between them to allow the HA database to be closed.

hassio.host_shutdown

Followed by:

button.nas_shutdown

OR

 button.nas_reboot

Another thought: If you’re using something like the MariaDB as your database you could stop that Add-On first, followed by the NAS shutdown/reboot command. That likely would prevent the database from becoming corrupted by an unexpected shutdown.