I created a bash script which performs the backup with dated file name, and with configurable source and destinations for the config files and backup. Just change the ha_dir and target_dir.
ha_dir='/var/homeassistant'
target_dir='/mnt/backups/Home Assistant'
use_date=$( date -u +%F-%H-%M-%S )
tar --exclude=home-assistant_v2.db -c -I"zstd -10 -T0" -f "$target_dir"/HABACKUP_$use_date.tar.zstd "$ha_dir"
tar -c -I"zstd -5 -T0" -f "$target_dir"/HABACKUPDB_$use_date.tar.zstd "$ha_dir"/home-assistant_v2.db
source and destination must NOT have a trailing / or it will not work correctly
I then insert this into my docker compose upgrade script before the pull
docker-compose down
./backup.sh
docker-compose pull
docker-compose up -d --build homeassistant
Now I only need to run a single script to update HA which now backs up all config in case I need to do a rollback, knock on wood
I could probably make the db compression ratio configurable, but I am going for the shortest downtime, and will manually cull the older backups