Keep 2 Raspberry up to Date

Hi there. I dont know if here is the right Place to ask.
My Plan is having 2 identical raspies with a homematic board and OH2; Influx; Homegear; Grafana and keep them synced in case one dies.
Perfekt would be a Delay of 1 day or so if I mess up something. So I could go back.
Basically I am looking for a mirror or Replikation Solution that brings over everything. And if the First one breaks I just set the Second active.

Looking forward to your ideas.
Mario

one idea would be: https://www.atlantic.net/hipaa-compliant-cloud-storage/how-to-use-rsync-copy-sync-files-servers/ (there are many tutorials on rsync). Here is another one: https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/

you may have to stop some services just before rsync fires on a cron schedule (e.g. InfluxDB) to allow the files to close properly. Copying open database (and other actively open) files is not really recommended.

Hi. Thanks a lot for your response
Yes I was thinking about rsync. Stoping the services once a night would be no problem. I’m just struggling what exactly to copy without breaking any keys and making sure the owners stay valid.

what do you mean by "keys"? (something like /root/.ssh/authorized_keys or something else?)

rsync should have no problem copying over permission and ownership settings (assuming the linux user already exists in the remote host). There are flags in the rsync command line to take care of this kind of stuff: https://linux.die.net/man/1/rsync

Yes. And as much as i know also homegear stores some keys

if these keys are stored in files: then rsync should have no problem copying them over.

Now… if these some of these keys depend on some hardware parameters that will change (e.g. the MAC Address of the Ethernet NIC)… you may have to re-validate/re-generate them when you bring live the standby system (rare case).