How to Bulk Delete Archive Emails from Confluence Database
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
データベースの操作方法が不明な場合はデータベース管理者にお問い合わせください。先に進む前にデータベースの完全なバックアップを作成するようにしてください。これらの SQL コマンドはいくつかの環境でテストを行い、意図したとおりに動作することを確認しています。
しかしながら、特定の状況や Confluence の新しいバージョンでは動作しない場合があります。これは、Confluence のデータベース構造に変更が行われている可能性があるためです。このため、問題が発生し、過去に動作していた状態の Confluence データベースへの巻き戻しを行う必要がある場合に備えたデータベース バックアップが必須です。
目的
- This KB outlined how to bulk delete archived mails tied to a Confluence Space. This is an alternative method, should deleting archived mails from Confluence UI fails e.g. due to the large number of archived mails stored in the Database.
- Delete Mail attachment in Confluence and the related file stored in the file system
ソリューション
データベースの変更を行う場合は 必ず事前にバックアップを取得してください。可能な場合はテスト サーバーで変更を試すことをおすすめします。
To bulk delete archive emails of a specific Space in your Confluence instance, you may execute the following queries in your Confluence database.
SELECT spaceid
FROM SPACES
WHERE spacename = '<AffectedSpaceName>';
CREATE TABLE IDTODELETE AS SELECT CONTENTID
FROM CONTENT WHERE contenttype = 'CUSTOM'
AND pluginkey = 'com.atlassian.confluence.plugins.confluence-mail-archiving:mail'
AND spaceid = '<SpaceIDIdentifiedFromThePreviousQuery>';
DELETE FROM CONTENTPROPERTIES
WHERE CONTENTID IN(SELECT CONTENTID FROM CONTENT WHERE CONTENTTYPE = 'ATTACHMENT' AND PAGEID IN (SELECT CONTENTID from IDTODELETE));
DELETE FROM IMAGEDETAILS WHERE ATTACHMENTID IN(SELECT CONTENTID FROM CONTENT WHERE CONTENTTYPE = 'ATTACHMENT' AND PAGEID IN (SELECT CONTENTID from IDTODELETE));
DELETE FROM CONTENT
WHERE CONTENTTYPE = 'ATTACHMENT'
AND PAGEID IN (SELECT CONTENTID FROM IDTODELETE);
DELETE FROM CONTENTPROPERTIES
WHERE CONTENTID IN (SELECT CONTENTID FROM IDTODELETE);
DELETE FROM BODYCONTENT
WHERE CONTENTID in (SELECT CONTENTID FROM IDTODELETE);
DELETE FROM NOTIFICATIONS
WHERE CONTENTID IN (SELECT CONTENTID FROM IDTODELETE);
DELETE FROM CONTENT
WHERE contenttype = 'CUSTOM'
AND pluginkey = 'com.atlassian.confluence.plugins.confluence-mail-archiving:mail'
AND spaceid = '<SpaceIDIdentifiedFromTheFirstQuery>';
To delete Mail attachment in Confluence and the related file stored in the file system
SELECT contentid FROM CONTENT
WHERE CONTENTTYPE = 'ATTACHMENT'
AND PAGEID IN (SELECT CONTENTID FROM IDTODELETE);
curl -v -S -u admin:admin -X DELETE http://<host name>:<Port>/confluence/rest/api/content/<Content ID> | python -mjson.tool
After executing the REST API, purge the deleted attachment in the trash and it will delete the attachment from the file system. Navigate to Space tools >> Content and Tools >> Trash.