Back it up
I was going to write something else for the introductory article here, but in light of a few posts on forums lately, I thought I’d start with something more important.
Lots of people run their home automation platform without giving any thought to backups until it’s too late.
Taking backups isn’t hard, but it also often doesn’t feel easy. Almost every modern operating system has tools to enable you to take regular, automated, backups. Those tools by themselves though might result in you just having one copy, which isn’t ideal.
Solving this is straightforward - you’re running on any kind of unix type system then you should investigate rsnapshot. This tool uses rsync to create rolling backups that are easy to restore. You can run it from another system to pull backups to it, or locally to a directly attached USB device.
If you want to have your backups outside the building, which is likely overkill for home automation backups, but not for other more critical data, then again there are many tools to help. I quite like rclone, which supports a wide number of online services, and can even encrypt your files before storing them online. Some of those services (such as Backblaze B2) even support versioning so you can recover previous versions if the copy you back up is corrupt.
Finally, if you’re running on a Pi then you really should check out rpi-clone. Attach a micro SD card reader and you can create bootable backups of your build.
All the backups in the world though are worthless if you can’t recover from them. Test and validate that recovery process, make sure you know what to do if the worst happens.
Corrupt SD cards
Probably the biggest reason you’ll need your backup is if you’re running on a Pi, and you have a corrupt SD card. The primary causes of this are either failing SD cards (whether of low quality, or bad luck), or power problems. If you’re on a Pi then ensure that your power supply is a good quality one, capable of providing at least 2.4A sustained, and that you’re using quality Micro USB cables, as short as possible. Short USB cables will reduce power loss.
You can check to see if your power supply is marginal by running
$ sudo vcgencmd get_throttled
If it returns something other than 0, see this article.