Automated restore of backup

I am building an automated installation of Home Assistant - with Supervisor
Most of the installation works just fine - but I am having issues restoring a backup during the process.

I am running the installer.sh which installs Home Assistant just fine.
First issue is that the installer.sh returns to my script before Home Assistant internal install is completed.

I handled this by checking “ha core check” and waiting for it to return “Command completed successfully.”

Now I copy my backup to the backups folder and run
ha backups reload
ha backups restore MYBACKUPNAME
This returns “Command completed successfully.”

Here comes the issue - the backup is not restored at all.
If I run the command manually (or restore from the UI) it works fine.
My guess is that Home Assistant is not ready for the restore just yet and I therefore need a better way to detect if the installation is complete than “ha core check”

Any thoughts?

untar the backup to /usr/share/hassio before running the installer.sh

That does not seem to work - it looks like the files are just overwritten by the installer.

Strange. That is more or less how I install a new installation of Supervised : copy the contents of /usr/share/hassio over to a new vm, and then run the installer. An untar should be the same.

I will double check my setup.

I am currently only copying one file - configuration.yaml. Could that pose an issue?

Yes, it will not work without copying the hidden directories in the config folder.

It seems to work. Thanks for your help!

@Hamsterman i am trying to get similar set up.

long story short: i want to shutdown my haos machine for certain time of a day. in that times a rpi should take over haos tasks. therefore i need a routine that restores a daily backup automatically to the rpi. maybe you can share your install script and i can make use of couple routines from it?!

best, goeste

Here is my full script which does more than just restore the backup:
/usr/share/automated/homeassistant.tar is my backup file.

mkdir -p /usr/share/hassio/homeassistant
tar -xf /usr/share/automated/homeassistant.tar -C /usr/share/hassio/homeassistant/
rm /usr/share/automated/homeassistant.tar
cd /usr/share/automated/
wget https://github.com/home-assistant/os-agent/releases/latest/download/os-agent_1.4.1_linux_x86_64.deb
dpkg -i os-agent_1.4.1_linux_x86_64.deb
rm /usr/share/automated/os-agent_1.4.1_linux_x86_64.deb &> /dev/null
wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb
apt-get -f --assume-yes -qq install
rm /usr/share/automated/homeassistant-supervised.deb &> /dev/null
mv /usr/share/automated/backup /usr/share/hassio/
echo "HOMEASSISTANT INSTALL COMPLETE"
1 Like

thank you @Hamsterman !!