Backup Best Pratice without snapshot

hello everyone
I curently test HASS on my barebone running on Arch linux (and it seem great!!).
On this barebone, run several service so I can’t use dedicated hass.io image during my test I would like to proced a restore from scratch. I have test some diferent method:

  • backup only configuration yaml file ans SQLite
  • backup only configuration yaml file and mariadb database

this two solution have failled I have observe that I need to backup complete hass config directory, python dep include this is the only way to get restore the complete interface
now I would like know, which is the best way into these choice:

  • backup entire config file with SQLite inside (I think this solution can corrupt database without stop hass service)
  • keep mariadb and dump database outside configuration (with the risk to have delta into the time of the two distinct backup)

do you have an advice on this question?

PS: folowing these test I have following these official backup doc and my point of view is if somebody follow this, he will can’t restore correctly his installation in case of complete failure so this procedure need to be refresh.

i normally just backup the whole config folder. Or the whole VM (running virtual)

1 Like

I backup the /config folder and nothing else. /config is the most important part of HA and that’s all anyone should ever need to backup (imho). The database (SQLite or otherwise) isn’t that important to me as I use InfluxDB for metrics and that’s on a separate server.

Hass itself (either venv, Docker, or hass.io) is easily able to be reinstalled within 15-20 minutes (which is the same amount of time that it would take to do a restore from a full drive backup anyhow), so there is rarely ever a need to backup the source files and folders. You could even keep a spare USB/SD card with a bare Home Assistant install just in case of a drive failure.

With that said, since you are running other services on the device, you could go with something like Duplicati, Restic, tar + gzip + rsync, amanda, etc for a complete system backup. But, I still wouldn’t grab anything in that backup relating to HA beside the /config folder.

Thanks for yours answer, i am agree I don’t need to backup all system ( I use ansible for other service and wish doing sale for hass) ,
My interrogation was mainly on database use.
You have said “isn’t that important” but on my short experience all the graphical configuration are store in database.

Nothing a simple rsync + tar + xz wong do. I have a cron job doing this daily and dumping to a server within the LAN setup to keep a max of 7 days worth of backup. It’s probably overkill, but you never know.

I exclude all logs and historical databases from my backup. The compressed file including the virtualenv that runs the whole thing and the important stuff from config/ is about 40Mb

1 Like

Not exactly. The UI portion (lovelace) lives in one of two locations; Either in /config/.storage or in ui-lovelace.yaml (/config/.storage/lovelace is a JSON file and ui-lovelace.yaml is a YAML file).

If you are talking about graphs and such (historical data), yes, that information lives in the database, however I don’t use it as I use InfluxDB. I get a huge performance boost by not logging anything to the recorder or the logger internally. Instead, all my metrics go to InfluxDB and then I use Grafana to chart metrics.

1 Like

THIS. I use 7zip instead of gz, but yeah, I’ve been doing backups this way for years now.

@flamingm0e recently turned me onto Restic and I like it. For a backup “system”, it ticks a lot of my boxes and it’s all command line. Plus, it has native support for rclone, which I like a lot as well. I’m slowly starting to migrate my backups over to Restic.

1 Like

Nothing critical is stored in database - only history information you don’t need to back it up or worry about it at all.

Not true.

1 Like

when you backup the whole config folder for HA, just tarball it and zip it? do we need to stop HA before tarball it?

Yup. tar -czvf [backup_location]/hass_"$(date '+%Y-%m-%d')".tar.gz --exclude='*.db' --exclude='*.log' [path_to_ha]

This command will create a backup with the current date as the file name (hass_2020-01-29.tar.gz). Replace [backup_location] with where you want to store your backups and [path_to_ha] with the path to your config directory (for a venv install, that’s usually /home/homeassistant/.homeassistant/).

Nope.

:smiley:

5 Likes

good, i have just test to backup config file include .storage that I have missing yesterday and it’s work great deps file don’t need to be backup every python dependance are download during first launch

thanks for your help now HASS answer to all my prerequisite!!!

Just saw this interesting conversation. I am pretty new, not that keen in Unix and just want to backup my yaml-files and other config.files on a USB stick. So does anybody have some guideance how to do it and what I have to prepare before.
I have in mind, calling such service afterwards with an automation in HA.
Any help? Thank you - Dave

Hi for my part I have a git repository in my config file and a cron commit daily modification every night and push the repository on my gitea instance (you can do same thing on github repo if you don t have selfhosted git forge)

Would you share your details how you implemented this? I am running HA on a Raspberry Pi and just want to backup some config files on a stick. Thanks

ok if you just want to backup to a stick easy way is just to do a CRON who run each night and this one can launch a rsync command who copy by example
rsync -a --delete --quiet /folder/to/backup /location/of/backup

OK, still struggling with integration of my USB stick, could this be done only with the internal terminal function or do I need to establish a SSH control via PC. USB Stick looks to be in /dev/media1 but I couldn’t change into this directory / drive to double check, really stuck here. Thanks

Your usb stick is plug on you raspberry right?
Do you have mount this to a mountpoint?

Yes it looks to be so, got it under media/USB-drive