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

The backup was done last night, with output set to "/" but I don’t find it in Dropbox… :hushed:

Hey @danielwelch - my backups seem to have stopped working … I think it’s related to the “skipping backups already existing in Dropbox” part, it says in the log that it’s skipped the backup for everyone of my local backup files, but also skips over ones that aren’t in Dropbox!

Any idea why this could be? Thanks :slight_smile:

I still can’t get it to work despite closely following the instructions. My log reads:

[Info] Files will be uploaded to: /hassioBackup/
[Info] Saving OAUTH_ACCESS_TOKEN to /etc/uploader.conf
[Info] Listening for messages via stdin service call…
{“command”: “upload”}
[Info] Received message with command upload
[Info] Uploading all .tar files in /backup (skipping those already in Dropbox)

Uploading “/backup/06edb32b.tar” to “/hassioBackup/06edb32b.tar”… FAILED
An error occurred requesting /upload
Uploading “/backup/12dd0a76.tar” to “/hassioBackup/12dd0a76.tar”… FAILED
An error occurred requesting /upload
Uploading “/backup/3bf4057e.tar” to “/hassioBackup/3bf4057e.tar”… FAILED
An error occurred requesting /upload
Uploading “/backup/5343cf50.tar” to “/hassioBackup/5343cf50.tar”… FAILED
An error occurred requesting /upload
Uploading “/backup/7f09d333.tar” to “/hassioBackup/7f09d333.tar”… FAILED
An error occurred requesting /upload
Uploading “/backup/9b92ce7f.tar” to “/hassioBackup/9b92ce7f.tar”… FAILED
An error occurred requesting /upload
Uploading “/backup/bcd69a30.tar” to “/hassioBackup/bcd69a30.tar”… FAILED
An error occurred requesting /upload
Some error occured. Please check the log.
[Info] keep_last option is set, cleaning up files…

Am I missing something?

So I re-set my config up - using app folder access (not full dropbox access) - and it took me a bit but realized that Dropbox was putting any ‘app folder’ access files within /Apps folder in dropbox… So if you assigned app folder access instead of Full dropbox permission, then you put “/” as the output folder in your HA config, you would find the snapshots in your /Apps/[Application Name]/ folder… not root folder…

So if you assigned ‘App folder’ access and you called your Dropbox API App as “Backups”, and you put say, “/hassio/” as the output folder in addon config, then you would find your .rar backup files in /Apps/Backups/hassio/ folder. I also created automations to handle the snapshots and running this add-on - every night starting at 3am. I picked that hour because I’m (usually) sleeping by then… and can check it when I wake up (3 hours later). Here’s the automation code I am using (most of the vital parts taken from another thread on this forum, though I don’t have the time to look for it right now or I would credit them).

I was lazy and just used two automations (you can script this a lot more intelligently but I am just verifying it works as it should right now which is has been). 1st automation is to perform the snapshot at 3am… 2nd automation is to upload it to dropbox 30 min later.

1st automation:

- id: '1542064264339'
  alias: Hassio Snapshot
  trigger:
  - at: '3:00:00'
    platform: time
  condition: []
  action:
  - data:
      name: Automated Backup {{ now().strftime('%Y-%m-%d') }}
    service: hassio.snapshot_full

2nd automation:

- id: '1542089370995'
  alias: Upload Snapshot to Dropbox
  trigger:
  - at: '3:30:00'
    platform: time
  condition: []
  action:
  - data:
      addon: 7be23ff5_dropbox_sync
      input:
        command: upload
    service: hassio.addon_stdin

Those are both in my automation.yaml file. That’s it. Super easy. Oh in configuration of the add-on it looks like the default really:

{
  "oauth_access_token": "my_token_code_here",
  "output": "/hassio/"
}

My App in dropbox is called Hassio Backup v2 . so in my dropbox folder it places the snapshots in: Apps/Hassio Backup v2/hassio/ folder…

Edit: the “name: Automated Backup {{ now().strftime(’%Y-%m-%d’) }}” doesn’t appear to be outputting the date … though the automation is working fine - just the title isn’t dynamic… I’ll fix it shortly.

1 Like

Just to confirm I need to enter the long string from the OAuth 2 section in dropbox?

You enter the “Generated access token” (it is in the OAuth 2 section) - a button you have to click for it show the api token - copy that into your config of the addon.

Hi all

It seems that the value in the keep_last field is not considered.
I have tried a number with and without double quotes, but I still find more copies than the one requested.
What is the correct form, with or without quotes?
Any other suggestion?

Thanks

it works for me.
“keep_last”: 5

My config is this

{
  "oauth_access_token": "xxxxxx",
  "output": "/myfolder/",
  "keep_last": 5
}

I can try removing all the files from the dropbox folder and let’s see what happens in the next six days…

Thanks

Why would you remove the backups from your Dropbox folder? The keep_last option applies to the local backups.

I thought that the keep_last field was applied to remote copies.

I’m just testing now, so I will start from scratch.

I will move my local copies to some other folder and have the local backup folder empty as well as the Dropbox one.
And start from the beginning.

Thanks

No it just removes them from Home Assistant. It does not touch Dropbox.
I run a script on my Windows 10 machine to move older backups to a different location so my dropbox doesn’t fill up. (The dropbox folder which is automatically sync’ed to dropbox)

1 Like

Thanks @DavidFW1960

Can you share your script, I will try to adapt to Hawaii on Linux.

ForFiles /p "C:\Users\david\Dropbox\Apps\Home-Assistant-Backups\home-assistant-backups"  /d -5 /c "cmd /c move @file E:\Dump\HOMEAU~1\HASSIO~1"

Or try this version, it has controls to keep last lical and Dropbox as well as some other features
. https://github.com/d0ugal/hassio-dropbox-upload

2 Likes

I like how Dougal’s also deletes old snapshots on Dropbox. Catching that Dropbox has filled up is a pain and if I was to have a disaster right now, my last backup was from the 23rd so I would lose a few days of data. Testing out Dougal’s addon now. And thank you for the head’s up on that.

Thanks @stocker

I’ll try this addon.

Great Addon. I just had a Pi go belly up and my most recent snapshot was from March. I couldn’t restore it, so I’ve had to manually re-do quite a bit. I really need automatic back-ups.

My suggestion would be to have the Addon also clean up old Dropbox files. Maybe have the Keep-Last apply to both local and remote, or have a Keep-Last-Dropbox that you can set to a different number.

Anyway, really appreciate the add-on. Despite being a developer for a living, I don’t know Python for crap, so I can’t contribute to HA until I learn.

You mean like the version four posts above yours :roll_eyes:

2 Likes

Yes, like that other, different add-on by a different contributor. I like this addon because of the ability to run the uploads with an automation. However if @danielwelch is no longer maintaining this one, then I will use the other.