Hassio 0.61 Snapshot Service


#1

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 (https://home-assistant.io/components/hassio/).

Thanks!

Dan W


Recovering a Snapshot?
Created new add-on to backup snapshots to Google Drive
Hassio 0.80.3 Snapshot service call options not working
Created new add-on to backup snapshots to Google Drive
#3

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') }}"

Hass.io Add-on: Upload hassio snapshots to Dropbox
Hass.IO service to make snapshot
Hass.IO service to make snapshot
Snapshot Service enhancement to USB-dongle
Repository: NotoriousBDG Add-Ons (Node-RED, HA Bridge, and Gogs)
#4

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

I was so close…

Dan W.


#5

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.


#6

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.


#7

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?


#8

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.


#9

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


#10

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


#11

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


#12

No. This is a hassio feature.


#13

Any intentions of adding Google Drive support? :slight_smile:


#14

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.


#15

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


#16

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.


#17

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.


#18

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


#19

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


#20

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.


#21

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