hassio-dropbox-sync
hassio-dropbox-sync copied to clipboard
Delete Dropbox files older than x
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
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.
@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:
- The
.tar
backup file includes asnapshot.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. - 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
IT will be great if automatic dropbox cleanup will be supported, +1.
Yes would be wonderful
How's this going? It'd be great to have this!
Looking forward for this solution 😊🤝
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
I need this feature to auto delete. I didn't know my dropbox was full and not backing up until I checked
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:
- Determine local tar size
- Check free space with Dropbox
- Delete oldest backup until sufficient space
- Copy local snapshot to Dropbox
- Repeat with next local tar