Backups of Hassbian

I’m not sure how a lot of you are handling your backups of Hassbian currently. I’ve done a search but some posts are back in 2016, I feel a lot of those backup processes have maybe changed. I’m running Hassbian on a RPI.

What I’m trying to achieve before I start doing more with HASS is this:

Have a nightly backup of my /config be sent to a folder on my Windows machine while I’m sleeping and nothing is really going on. Also have that same backup be uploaded to Google Drive.

Once a month, have the entirety of the SD card be backed up to my Windows machine and Google Drive.

Have an entire SD card backup (or equivalent) performed before updating to new HASS versions.

I’m not sure if this is overkill or not enough really. My current backup method is just transferring my YAML files to a folder on my PC manually. However in the event of a bad update to a new version, corrupt SD card, etc - I would still have to setup everything again like appdaemon, etc. However if that is needed, I have kept documentation of everything outside of HASS that I have setup and installed. Would just be copy and paste command lines from that document at that point.

I have setup Webmin, I just need to mount a shared Windows directory and setup scheduled backups. Haven’t looked into the Google Drive part yet.

1 Like

I’ve got a more complete write up here, but in summary:

  • rpi-clone - run manually once I’m happy that the upgrade has worked, so I’ve always got a trivial recovery
  • rsnapshot - running on another Pi, backing up my entire system every other hour (the blog article says 4 hourly, because I assume most people aren’t quite as paranoid)
  • rclone - running hourly and pushing (an encrypted) backup to the cloud (in my case, Backblaze B2)

Taking this in order, and why

  • This covers both SD card failure, and also a significant failure when upgrading (though mostly for a failure I’d just manually downgrade, or restore the working venv backup)
  • Most issues are likely to be my messing things up, so I can easily reach over and grab the previous version of the file
  • Covers catastrophic issues - the house being flattened by a falling sperm whale, or fire, or theft

IMO if you’re not backing up your data and configurations at all then you’re saying that it (and your time) don’t matter. If you’re not backing it up to somewhere offsite, then you’re saying that you don’t care that much :wink:

Oh, two very important points for anybody:

  • Automate the backup (so you don’t forget)
  • Test the restore regularly (so you don’t discover you can’t restore because all your backups have failed)
2 Likes

I just put in a second SD Card and used rpi-clone to clone the SD. Since it requires input a couple of times, don’t suppose there is a way to automate that?

You can modify the script (it’s just a shell script) to remove those prompts.

However, given that this is your only bootable backup. You really want to know if creating it fails. If you’re going to do that you need to make sure that you automatically get told about the status of the backup.

1 Like

I thought about that once I asked the question. I would want some way to get emailed or something to let me know if the clone didn’t work. That would be the only way I set it to auto.

I have setup rclone now to run an hourly backup of /.homeassistant using cron to my Google Drive folder. I now need to have it encrypted before it uploads as well as exclude things like OZW logs, etc.

What I would like to do is have rclone create a directory in Google Drive with the date and time and then upload to that directory. So each upload would have its own directory. I haven’t looked into rclone that deeply yet. Then I want to setup some type of way to notify is a cron job fails.

I’ve been using Home Assistant as an opportunity to increase my pretty low knowledge of linux as well. So basically, I’m learning as I go. After the online backup is taken care of, I’ll work on backing up to my Windows PC until my home lab is setup.

Just realized about Google Drive’s versioning so creating directories is moot. I’ve also gotten my excludes sorted so encryption is the last piece.