hassio-dropbox-sync icon indicating copy to clipboard operation
hassio-dropbox-sync copied to clipboard

Delete Dropbox files older than x

Open freekeys opened this issue 6 years ago • 9 comments

Hi there,

Firstly thanks for this awesome add-on, it’s working brilliantly for me!

I’m running into the problem that my Dropbox account is getting filled up with snapshots...

In the interests of having things automated, could we look at having the script clear out Dropbox snapshots older than a certain date? Looks like there is precedent here: https://stackoverflow.com/questions/41098278/delete-files-after-certain-date-with-dropbox-uploader-sh

freekeys avatar Jun 10 '18 17:06 freekeys

Thanks for the link! I’ve thought about this before, but wasn’t sure off the top of my head if it was possible using the Dropbox uploaded script, looks like it’s possible! I’ll try to work on it in the next couple of days.

danielwelch avatar Jun 10 '18 23:06 danielwelch

@freekeys Ok, after looking into this a little, it looks like the best way to do this would be to add a dependency and deal with the Dropbox API directly rather than using the dropboxuploader.sh script.

The technique in the link you provided, while helpful, relies on the date being in the filename. While most people probably do have the date in the filename, we don't know where or in what format, and have no guarantee it's there, so I'd rather not use a solution that relies on just looking at the filename. It doesn't look like there's a way to access file metadata with dropboxuploader.sh

I see two other possibilities:

  1. The .tar backup file includes a snapshot.json file with metadata including the datetime of snapshot creation, but sorting and acting on that would involve downloading and unarchiving every single backup in the directory. Gross.
  2. We can just bite the bullet and use the Dropbox Python API, which can give us the metadata we need for each file to sort on.
    • https://github.com/dropbox/dropbox-sdk-python/blob/fb9a5311017480738faf88d9a2675cf8289367b0/dropbox/files.py#L2754

danielwelch avatar Jun 15 '18 13:06 danielwelch

IT will be great if automatic dropbox cleanup will be supported, +1.

wiatrM avatar Nov 29 '18 20:11 wiatrM

Yes would be wonderful

hiol83 avatar Dec 17 '18 01:12 hiol83

How's this going? It'd be great to have this!

iAbadia avatar Jan 25 '19 20:01 iAbadia

Looking forward for this solution 😊🤝

PrathikGopal avatar Jan 27 '19 23:01 PrathikGopal

Those waiting for this, I just switched to this plugin which already deletes snapshots over the limit from both Hass.io and Dropbox:

https://github.com/d0ugal/hassio-dropbox-upload

AlecRust avatar Jan 28 '19 10:01 AlecRust

I need this feature to auto delete. I didn't know my dropbox was full and not backing up until I checked

ikifar2012 avatar Apr 26 '19 20:04 ikifar2012

In my case I would be happy if the addon would only remove the oldest snapshot(s) when the Dropbox is too full. I have a dedicated extra Dropbox account with only 2GB.

So basically the logic should be:

  1. Determine local tar size
  2. Check free space with Dropbox
  3. Delete oldest backup until sufficient space
  4. Copy local snapshot to Dropbox
  5. Repeat with next local tar

metbril avatar Dec 18 '19 04:12 metbril