Bbackup strategy?

Hello,

I am looking at the need to backup Hass, and am a bit unsure about where the need-to-backup files are!

Sorry if this is a stupid question.

To me, there are two types of backup, incremental and image. Both have different uses. For example, if the SD drive becomes corrupt, it would obviously be most convenient to just swap it for an image backup. This implies that the image is an exact copy of the SD before corruption.

There’s the rub: what if the corruption (or programming error) carried across to the image? Obviously it would be as useless as the original.

That’s where the incremental backup comes in. With it, you can go back to before the error and reconstruct the environment.

With this in mind, it seems the best way for an image would be to have a spare SD card sitting in a USB adaptor and cloned to on a regular basis (daily?).

For the incremental backup, I’m thinking that my Mac already does that, so to ‘leverage’ that facility, I’d want to incrementally backup relevant files.

… so, my question to you is: does the Samba share provide access to all the Home Assistant files outside the operating system and an initial install?

The reason I ask this is that a lot of file-based configurations have been disappearing, presumably into the database, which it more opaque for managing backed-up errors…

Thanks in advance!

Karl

For starters all the configuration yaml files should go into a backup, perhaps also some of the .storage folder contents (e.g. restore_state in case the entity is not recoded into a database).

On the HA docs they explain how to backup to a private GitHub repository. (See Git if you don’t know what it is).

What I do is I regularly commit and push my changes with a useful commit message. I’ve made a DD clone of the sd card and have an identical spare laying around for the day that it breaks…
If that happens I can DD my clone to a new sd card and just do git pull.

Just make snapshots regularly.

Worse comes to worse, re-image a new SD-card and restore the snapshot. Of course use the dropbox or gmail backup to store snapshots.

That’s where you’re wrong. The database doesn’t contain the configuration. They are still in files in the .storage directory

1 Like

On Hass.io you’ve got snapshots, which are great until the SD card fails. I’d suggest you look at the Google Drive backup or Dropbox sync add-ons.

You should also be able to use the SSH & Web terminal add-on to use something like rsync for remote backups.

Ah - I see - all clearer now!

Do the .yaml files override the settings in the .storage directory?

Thanks @flamingm0e!

Thanks for the replies everybody!

I’ll try going with the snapshots.

Because I don’t like the way seemingly everything on the internet is being shared, ‘monetised’, and breached at the moment, I’ll do the following:

  • run Samba on the Hass Raspberry Pi,
  • use a Mac app (Carbon Copy Cloner) to regularly update mirrored copies on my desktop drive
  • allow the built-in backup software (Time Machine) to provide an incremental backup of the mirrors.

Thanks guys!!

Depends on the integration. More and more integrations are moving to the .storage registry.

Karl,
As moe implies ‘data’ is often stored all over the place (not literally but you have to remember what-where) as he also suggests Snapshots are the way to go, and ignore incremental backups, you then have to know which full backup you are incrementing from. Snapshots store all relevant changes from a naked HA installation (everything you need). My largest backup to date is about 3.5MB, that’s piffling compared to when I used to shut HA down and image a 16GB card to a file, then compress that file because they mount up and anyway I use 32GB cards now.
So yes backup regularly, especially before and after any major integration or ui work or adding major bits of automation/scripts.
I assume you know where the snapshots are? (under hassio, snapshots)
Then use samba to copy the snapshots off your card (they are stored in backup which is a sibling of config (go to the parent of config and it’s there)
I usually put a folder in config called (say) “backup 2019090701” or similar, yearmonthdaysequencenumber so they stay in relevant order. I can then drop the backup (careful these are tar files named (as far as I can make out) in a system generated manner obscure to man) hence why I drop them in a folder that means something to me. I also have a short cut (two actually) in the config folder so I can drag the folder there for copy to local hard disk and NAS. I quite often drop in ‘some’ of the files I have been working on as well.
Should you lose your sd card, simply write a new one (10 mins) install samba and SSH, copy your tar file into the backup folder, reboot and restore, another 10mins max. Just make sure you have at least 1 spare card as waiting for one to come in the post ‘may’ result is a loss of WAF.

Oops ! Posted this to another thread … it should be here.
Sorry, forgot one thing. For Z-Wave Stuff your Z-Wave Stick (or whatever) remembers your Z-Wave Network Configuration. The naming etc. is done in HA though.

Thanks a lot everybody!!

Yes, it’s a shame the file names of the snapshots aren’t informative, but at least the modification date is preserved!

As additional completion: use samba-backup from here