Hassio 0.61 Snapshot Service

In the release notes I saw that they have added the ability to create Hassio snapshots through a service call:

Pascal has made it easier to create and restore snapshots for Hass.io by calling the new services. This way it will be easy to automate the creation of a snapshot at night. The updater has also been fixed and will now report on new versions of Hass.io that are available.

Has anyone seen any documentation around this feature? I was digging through the code and looking at the hassio component and see mention of a snapshot ability, but no documentation around how to use it. And the documentation link in the code does not work (Home Assistant Supervisor - Home Assistant).

Thanks!

Dan W

1 Like

A full snapshot via the UI looks like this:
image

An automation that performs a daily snapshot looks like this:

- alias: Daily Backup at 3 AM
  trigger:
    platform: time
    at: '3:00:00'
  action:
  - service: hassio.snapshot_full
    data_template:
      name: Automated Backup {{ now().strftime('%Y-%m-%d') }}
  - service: notify.slack_notify
    data_template:
      message: Creating backup named "Automated Backup {{ now().strftime('%Y-%m-%d') }}"

A partial snapshot of just the Node-RED addon via the UI looks like this:
image

An automation that performs a daily partial snapshot of just the Node-RED addon looks like this:

- alias: Daily Backup of Node-RED
  trigger:
    platform: time
    at: '3:00:00'
  action:
  - service: hassio.snapshot_partial
    data_template:
      name: "27e642c6_nodered {{ now().strftime('%Y-%m-%d') }}"
      addons:
        - 27e642c6_nodered
  - service: notify.slack_notify
    data_template:
      message: Creating backup named "27e642c6_nodered {{ now().strftime('%Y-%m-%d') }}"
33 Likes

Thank you for walking me through this with such detail. That really helped a lot!

I was so close…

Dan W.

1 Like

Thanks, this is really useful!

What about rotation of backup files?
I don’t want to fill up my SD-card with backups :slight_smile:

Also: A way to copy the backup-files to some external storage (e.g. with scp) would be very good.

5 Likes

Not a scp solution, but the easiest solution for me was to create a scheduled task on my DC to call a simple batch script after the snapshot was made to copy the contents of the \\HASSIO\backups directory to another PC that I use essentially as a NAS device and then delete the contents of the backup directory.
Doing this from Windows means Samba has to be installed and configured.
The batch script looks like this:

@ECHO off
SET Source=\\HASSIO\backup
SET Target=\\SERVERNAME\share\Hass.IO_Backups
SET Date=_%date:~-4,4%%date:~-7,2%%date:~-10,2%
IF NOT EXIST "%Target%" MD "%Target%"
FOR %%i IN ("%Source%\*.*") DO ^
COPY "%%i" "%Target%\%%~Ni%Date%%%~Xi"
IF EXIST "%Target%\%%~Ni%Date%%%~Xi" DO (
DEL "%Source%\*.*" /Q
)

Keep in mind my snapshots aren’t appended with the date like NotoriousBDG’s are. You’ll probably want to drop that from either the automation or batch script.

2 Likes

Is it possible to do a daily snapshot to a USB-dongle (on a RPi3), and to get a notification only if the backup proses fails?

I’m working on an add-on that allows you to upload your /backup directory to your Dropbox.

Currently, you have to manually start the add-on to trigger the upload to your Dropbox, but I’d eventually like to make this a more automated process (as I discuss at the bottom of the README). I think this combined with the snapshots automation here would be really nice.

5 Likes

+1
Great Job! Please complete the automatic upload :wink:

I’ve updated the add-on to v1.0.0. The uploading is triggered via a service call, so it can be automated just as any other home assistant service (like making snapshots) :wink:

See here for more. @ezar

1 Like

Can any one explain me if this is an option in the full ha version in a venv?

No. This is a hassio feature.

Any intentions of adding Google Drive support? :slight_smile:

Coincidentally I just answered a question about google drive in the main project thread. I think it’d make more sense to do it in a separate add-on, but since you’re interested I’ll look into making one.

3 Likes

How about an option to make backups using scp as well?

I went ahead and made a shell_command instead

shell_command:
    copy_backups: scp /backup/* wdmycloudmirror:~/hassio-backups
    delete_backups: rm /backup/*

If I ssh into hassio and run scp /backup/* wdmycloudmirror:~ then it works just fine using ssh keys, but if I call the service trough hassio then I get an error code 1. How come?

Is /backup/ not accessible from shell_command? One has to create a docker? I have no experience with that though - dang. Probably time well spent anyways.

1 Like

When you use the shell_command component, you’re calling that command from Home Assistant, which runs on Hass.io but is not the same and is designed to have restricted access. As you say, implementing your shell command as an add-on would be the way to go if you want to trigger it or automate it from the front end.

I cant find this in the docs anywhere, what is the difference between partial and full snapshot?

Try clicking on it and you will find out what the difference is maybe?

I’ve now created an addon that creates a snapshot, copies it to a remote server location using SCP and then removes the local snapshot again. Then I have a simple automation script that starts the addon every day on timed schedule.

At the moment I’ve just made it local but let me know if anybody wants be to distribute on Github.

2 Likes

Yeah, dude, if its not too much trouble. That’s a rad add-on. I’m sure many will us it.