Maybe I have seen this and maybe there are some floating around, but does anyone know of a good way to schedule daily or weekly backups in HA? With all the improvements which there is probably more than I need I cannot believe scheduling backups are not in HA by default. Yes, I am aware you can run manual ones. Just looking for something reliable.
thanks. External backups would be nice but for now I am just looking to back it up locally. I’d have to check some older posts, but I am pretty sure from ha > command line I can kick off backup. I just never got added in as script that could be automated.
#!/bin/sh
# Stop Home Assistant
ha core stop
# Create Backup
ha backups new --name "Automated backup $(date +%Y-%m-%d)"
# Start Home Assistant
ha core start
It is really, really not advised to safe a backup only locally. It is like don’t doing a backup at all… And trust me, we all know what we’re talking about. But I trust in you, that you at least download a backup to your local machine (eg. your laptop).
That being said, and not to sound to much like a teacher, have you taken a look at the above linked Add-on from @sabeechen? It allows for the automated backup and optionally an upload to GoogleDrive.
Trust me, this Add-on is what you want. Setup a password and it is even ok-ish to upload it to Google. If someone does the effort to encrypt your password protected HA config, it is more likely that that person or organization has already other things hacked from you. Assuming you used a strong password…
Seriously, check out the Add-on, it is the de facto standard for automated backups in HA, and it is very well maintained!
Couple things. I appreciate the feedback, but just because I might be a newbie with HA doesn’t mean with IT in general. So the first thing of which I’d like to point out is I did not get chance to revise my last post before you replied. The next is if I am going to back up to somewhere it will probably be something other than Google. Need I say this company doesn’t exactly have the best reputation when it comes to privacy? The other thing is your assuming perhaps HA is running on a local computer. Incorrect, it was initially running as a VM on a separate IoT vlan in Ubiquiti home network. It is now running on a dedicated HP Micro Mini. You are correct that I do at times download a backup of HA to my local computer.
I was able to get Samba Backup installed and for now whether you disagree with me which I am guessing you do I just want to do a local backup. Once they are working I will certainly want to upload to my Dropbox. Just prefer to not use the guys (Google) that want to know what tissue paper used when you go to the crapper.
If you had said so from the beginning, my answer would’ve been another. So next time just tell people what you’re after and what your capabilities are, so they can give you an answer, that fit your needs. On the other hand, with that attitude you might get not that many answers as you had hoped for.
No attitude and didn’t think it came off that way. By the way your reply to me came off as if you were talking to an someone ill informed and a bit obnoxious (And trust me, we all know what we’re talking about). You may want to choose your own words little more carefully. Some people might not take kindly to that, even with good intents.
If you think Google is all fine and dandy, go read what the European Union courts have said with them and blatant disregard for privacy.
As it turns out I found my answer for automated scheduled backups via the video below. Guess sometimes have to look further and ignore certain elements who say trust me we know what we are talking about. Really, than why was what I found not posted as I clearly stated what I was looking for. I’d comment further but why waste my time when I supposed to believe egoistical individuals that want me to trust them. I am not referring to the people on these forums in the past who have helped me just the last one who replied to me.
Just to save anyone else the pain of skimming a 17 minute Youtube, you can create an automation in HA to run whenever you want (assuming it’s within a 24hour period - creating 25+ hours requires some finagling).
In the Actions section, search for ‘backup’ and select ‘Home Assistant Supervisor Create a full backup’.
Alternately, if you are comfortable with the CLI, you can simply run backup creation as a cron job. Save scripts under one of the following directories to have it run at the specified frequency:
/etc/periodic/15min
/etc/periodic/hourly
/etc/periodic/daily
/etc/periodic/weekly
/etc/periodic/monthly
Here’s a script I put together for the purpose, which additionally pushes the new backup to a remote VPS:
#!/bin/bash
slug="$(ha backups new | grep slug | awk '{ print $NF }')"
scp /root/backup/${slug}.tar my.ssh.server:home-assistant-backups/
# keep only last four backups
cd /root/backup; ls -t | tail -n +5 | xargs rm
ssh my.ssh.server 'cd home-assistant-backups; ls -t | tail -n +5 | xargs rm'
Saving the script to any of the folders will automatically schedule it. I’m looking into the same thing and I have not tested Ryan’s script but I believe that the script assumes that you have SSH keys in place for authentication and a directory on the target server called home-assistant-backups.
Ryan the script is simple and elegant. SCP is cool. I’m trying to work out how to do this up to a box I have on the net from about 18 different HA boxes in a secure and scalable way.