Any api to purge old deleted posts / uploads

Our discource is runing out of space on server.
We did bulk deleted old posts whit uploads.
But We did not gain any space.
When I query table topics they only havetopics.deleted_by_id is not null
Uploads for these topics are still on server.

Is there any way to make this Uploads orphans so sidekiq can clean these?
Or is there any way to PRUGE deleted topics so they do not consume space any more ?

I saw auto purge uploads from old deleted posts , but one year has past since post maded whit no replays.
So I started searching my way to release space on server

1 个赞

Any thoughts @zogstrip?

Not sure how you bulk deleted the old posts/topics but this should fix it

# ssh into server
cd /var/discourse
./launcher enter app
rails db
DELETE FROM post_uploads WHERE post_id IN (SELECT id FROM posts WHERE deleted_at IS NOT NULL)
5 个赞

We did delete post from advanced search result page


1 个赞

Here is my tsql for deleting uploads

Warning

This tsql delete uploads from post whic is not deletete but belong to topics whic is deleted.
I do no why discource left undeleted posts when topic is deleted.
But from my poin of view.
If topic is deleted, then all posts shoud be deleted in topics. Not just first one.
This script delete uploads for all posts which belong to deleted topic no matter if post is deleted or not.

delete from public.post_uploads
where id in (
SELECT 
	post_uploads.id
--    ,uploads.filesize
 --   ,posts.id
    --,topics.id
FROM 
  public.topics
  inner join public.posts on topics.id=posts.topic_id
  inner join public.post_uploads on posts.id=post_uploads.post_id
  inner join public.uploads on post_uploads.upload_id=uploads.id
WHERE 
	topics.deleted_by_id is not null
  )

I am not for sure which of sidekiq jobs need to be triggered , but I get released space after manual triggering next Workers in scheduler

  • Jobs::CleanUpUploads
  • Jobs::PurgeDeletedUploads
  • Jobs::DirectoryRefreshDaily
  • Jobs::DirectoryRefreshOlder

And called sudo ./launcher cleanup over SSH.

2 个赞

求助呼吁!

有没有聪明的人能指导我如何将以下两部分结合起来:

以及

以便在控制台中运行一个强大的孤立文件清理程序?

我注意到,当我使用 rails db 时,系统会提示输入 Password for user discourse:(discourse 用户的密码)。我该如何处理?

回答我自己的问题:

实际上,这现在已经过时了。至少对于帖子而言,删除已删除主题中的帖子这一问题已在之前得到修复。

早于该时间的帖子仍需要某种巧妙的解决方案。

请使用 app.yml 中的 DISCOURSE_DB_PASSWORD。

1 个赞