I’ve seen a lot of info on the forums about shutting down host operating system, but what I need is to cleanly shutdown HA itself, which I have running in Docker on a Synology NAS. I’m not sure if simply shutting down the container is going to shut it down without breaking the recorder database.
Basically I have a scheduled task on the Synology NAS shutting down the Docker container every night to back up config files, then restarting the docker container.
Is there a better way to do this? Command line or something to cleanly shutdown HA? Maybe can put that in the backup script or in the Docker container’s shutdown script?
I have HA running in a container, and I don’t shut it down when I back up my configuration. Sure, I get the message blank has changed as we read it, but it has seemed to work for me. I have had to use those backups when I had a HDD failure on my machine running HA, and there was no data loss (outside of the information between the backup and the restoration).
I don’t automate my backup, every time I make some major changes to my configuration I make a backup. I have a script that backups the configs of a few docker configs and puts each one in its own tar ball and names it with the Application Name and the current date in the file name. Then I manually copy it off the docker machine to my NAS.
If you are concerned with data loss of sensor data, then I would look into exporting to something like InfluxDB.
I’ve been backing up the entire config directory. When I do that with HA running, it breaks the HA database. Should I just exclude the database file from the backup and run the backup with HA running?
Also I have had no issues shutting down the system without stopping HA. I have also had no issues backing up the config folder while HA is running, there do not appear to be any locks that prevent it, and the contents of the backup look just fine.
If you plan on doing this in a cronjob then I would just comment out all the echos.
I have the echos in since I run it on the command line manually; although I think my automated scripts have more info since I send statuses to MQTT (for some, not all)
I’m not sure I like splitting the automation like that, but in the end that might be the way to go. Or just exclude the database from the backup, leave HA container running, and call it a day.