-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Need to be able to safely cleanup local content #3479
Comments
I think the way to solve this right now is to delete files older than X days and larger than Y bytes (e.g. find /var/lib/matrix-synapse/media -size +50M -mtime +365). I have the same issue because my private homeserver on a tiny 10GB VPS is 3/4 full of videos of kids. I've used this method to clean up some files and it just results in a blank message in Riot from what I can see. (I can't get the purge API to actually purge, but that's a separate issue) If there's a better way, I'm happy to be corrected. |
You can do that but the database records linking to that content would not be removed. Same problem with the local thumbnails, you need to remove the database rows or else the thumbnails won't be regenerated on access later. I think there should be a single cleanup API that takes care of all the local and remote content, including thumbnails and URL previews. |
I wrote a simple tool to clean up local content tonight. |
I agree, it would be great to have a way to clear the local content without destroying all avatars. I have created a shell script to clean this repository, but as said by @rkfg, this also delete the avatars, even if I save and restore their files (because the local thumbnails are not regenerated after the clean). |
This is solution for pgsql, do u have one more for sqlite? :)) |
We made synapse-purge to purge remote media cache, local media and events in all rooms (both encrypted and unencrypted) until "x seconds ago" for the Synapse server, feel free to use it. It is highly configurable and should work on all instances using a Postgres database. This also preserves only the most recent user and room avatars and will remove old ones. |
Hello there. The next major release of Synapse should include an admin API to delete local media by timestamp of last access (which helps exclude avatars) and file size. This was introduced by #8519, with documentation on how to use it located here. I'm going to close this issue now. Feel free to open another issue if you have any further requirements 🙂 |
Hi, thanks @anoadragon453 for the response, and the great feature ! I was really waiting for this one :D I tried using the API to delete local media (using -X POST https://<server_name>/_synapse/admin/v1/media/<server_name>/delete?before_ts=xxx) but I get a response
Is it implemented in 1.22, or will it be in a next version ? |
This will be in 1.23.0. |
Ok, thanks @clokep ! I was being too impatient, sorry :D |
I'm running 1.24.0. Is this time based feature ("before_ts=") working for you? I just get |
Yes, it's working ! Is your timestamp in Unix format, in ms ? Beware, by default the "date" command does not include the milliseconds. I am using this argument to delete the files older than 60 days:
|
My bad. I used Unix timestamp in seconds, not milliseconds... |
I am running into some very tight disk space issues and I need to clean out as much old data as possible. But, the request is not working for me?
what am I doing wrong here? (BTW - I am using the fish shell. I used |
Do you send a header with token? Is the user HS admin? |
Ohh. None of the replies here had mentioned the header. Yes - I didn't send a token. That said, is there a way to clean out local and remote media at once or do I have to go through each and every remote server (which I could probably automate with |
@IngwiePhoenix That will need to be a
I'm afraid this endpoint is a bit confusing, and I've created an issue for cleaning it up a bit: #9284
So this will remove media uploaded from anywhere - you don't need to specify each individual remote server name. See the media admin api docs for more information. |
Not the caches, the content itself. People sometimes upload big files like videos or highres photos and they stay in the storage forever. Currently there's no way to find these files and delete them after some time safely. The problem is that avatars (for example) are also stored in the same storage and just deleting everything older than N days would effectively purge every user and room avatar if they're set a while ago. I also noticed that purging history with the API doesn't delete the media attached to the purged events. In the end the storage would grow indefinitely which is quite a problem.
So I would like those files to be removed if no events use them (including the forwarded ones), that's how it should be. I know that redacting doesn't actually remove the content from the database just yet but it's unreachable and the media should be too.
But also I'd like to be able to remove media using some criteria like date range and file size and be sure that it doesn't break anything. Sure, easy find -size ... -delete would do but this really should be managed by synapse itself.
The text was updated successfully, but these errors were encountered: