Hass.io Add-on: Upload hassio snapshots to Dropbox

I’ve just uninstalled and deleted the repo. now restarting HA and I’ll try installing again to see if that helps.

ah. It’s also now not creating a backup folder underneath the folder you specify…

So if I look in my DropBox, I have:
Apps
Apps\Home-Assistant-Backups
Apps\Home-Assistant-Backups\backup - this is where my backups ended up with the original Add-on
Apps\Home-Assistant-Backups\home-assistant-backups - this is where my backups are now going with the new addin.

My Configuration looks like this:
{
“oauth_access_token”: “xxxxxxxx”,
“output”: “/home-assistant-backups/”
}

So I think the changed way is what makes sense now.

It also worked after removing the repo and adding it in again. Nice.

One further thing - an enhancement - would it be possible to configure how many backups it keeps in the source? So everything could be backed up but then it will delete the oldest backups so you are only keeping ‘x’ number of backups locally? That would be great.

So sounds like things are working as expected?

I can look into this. It seems like it should be possible but the addon will likely be required to use the hassio API. I’m imagining an option keep-last, which if set, will trigger calls to the hassio api to get date of all snapshots, and delete all but the last 5. I’d probably implement this in a separate python script. That’s run after an upload and only if keep-last is set.

Alternatively, this functionality could be exposed as a separate command, with its own option for keeping the last N snapshots.

Will try as well

Yeah totally working. Thanks.

Actually with keeping snapshots, it would be even better if it was handled in the Hassio Snapshot function anyway. There is no way to even delete snapshots from the GUI - all you can currently do is delete them in Samba or scp, so if this could be run from your addin would be handy.

Thanks again.

I was experimenting with an addon that copies backups to a thumb drive and handles keeping the last x backups. It’s very simple bash code, but If it helps, check out what I did at Snapshot Service enhancement to USB-dongle - #3 by NotoriousBDG.

I prefer your Dropbox approach over what I was doing with thumb drive. Dropbox is much more flexible and it’s nice to know backups are stored in the cloud…

1 Like

with 0.63.3 you can now delete snapshots from the GUI. Something I’m very happy to see implemented :slight_smile:

Anyone made an automation to run this regulary? Maybe even executing a snapshot before?

Would this work?

homeassistant:

automation:
- alias: Daily snapshot 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') }}


- alias: Daily upload to dropbox at 5 AM
  trigger:
    platform: time
    at: '3:00:00'
  action:
  - service: hassio.addon_stdin
    data_template:
      name: {"addon":"7be23ff5_dropbox_sync","input":{"command":"upload"}}

btw, thanks for a great add-on! Been looking for a good way to backup my config since I moved to hass.io

2 Likes

This is what I did but set Dropbox upload to 4am, as the snapshot can take some time to run.

I see no way to do this - even before the GUI change (system tab is blank with half the old functions not visible)

I just have 2 seperate automations. The backup one runs an hour after the snapshot one and also notifies me it is complete. Running both at the same time won’t work as it needs time to make the backup.

This looks like something I will be including in my configuration. I was curious about having an automated backup. How about updating to Google Drive or a private FTP instead? Is it simply pointing the code to those specific locations and credentials?

There are other add-ons for FTP, including one in the Community Add-on repository which I assume is good.

This add-on makes use of the Dropbox-uploaded bash script. Uploading to Google Drive would probably best be implemented in a separate add-on. I can look into making one if there’s interest.

5 Likes

I like the idea of using Dropbox instead honestly. I was just curious about the other options. I have not actually installed HA yet and I am not familiar yet with the available add-ons. Hopefully tomorrow all my RaPi parts come in so I can get starte! Thanks @danielwelch

here it is on 0.63.3

Ah thanks for that - I hadn’t tried clicking on it.

Forgot to update the “at” time, I’m running it 2 hours after snapshot, but something is not working correctly, I’m guessing I got the data_template wrong, what does your automation look like?

I’m trying to make this work, but getting error’s in the log.
I just installed the addon today, after updating HASS.IO to 6.4.
This is what I’m getting:

Invalid service data for hassio.addon_stdin: extra keys not allowed @ data['name']. Got {'addon': '7be23ff5_dropbox_sync', 'input': {'command': 'upload'}}
required key not provided @ data['addon']. Got None
required key not provided @ data['input']. Got None

Any clue why? I tryed uninstalling the addon, and readding repo, same error when triggering automation…

Any update on getting this to only retain the last 3 or 5 backups for example?

I haven’t given this a shot yet. It is probably possible to do something like this using the Hass.io API, which would let me get the date for each snapshot. I’ll try to add that functionality soon.