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 データベースへの巻き戻しを行う必要がある場合に備えたデータベース バックアップが必須です。

目的

  1. 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. 
  2.  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.

Identify the SpaceID of the affected Confluence Space
SELECT spaceid 
FROM SPACES 
WHERE spacename = '<AffectedSpaceName>';
Create temporary table in your MySQL Confluence DB to store all of the Archiving Mails information
CREATE TABLE IDTODELETE AS SELECT CONTENTID 
FROM CONTENT WHERE contenttype = 'CUSTOM' 
AND pluginkey = 'com.atlassian.confluence.plugins.confluence-mail-archiving:mail'
AND spaceid = '<SpaceIDIdentifiedFromThePreviousQuery>';
Deleting related information of the Archiving Mails stored in CONTENTPROPERTIES table
DELETE FROM CONTENTPROPERTIES 
WHERE CONTENTID IN(SELECT CONTENTID FROM CONTENT WHERE CONTENTTYPE = 'ATTACHMENT' AND PAGEID IN (SELECT CONTENTID from IDTODELETE));
Deleting related information of the Archiving Mails stored in IMAGEDETAILS table
DELETE FROM IMAGEDETAILS WHERE ATTACHMENTID IN(SELECT CONTENTID FROM CONTENT WHERE CONTENTTYPE = 'ATTACHMENT' AND PAGEID IN (SELECT CONTENTID from IDTODELETE));
Deleting the attachments of Archiving Mails records from the CONTENT table
DELETE FROM CONTENT 
WHERE CONTENTTYPE = 'ATTACHMENT' 
AND PAGEID IN (SELECT CONTENTID FROM IDTODELETE);
Deleting the Archiving Mails records from the CONTENTPROPERTIES table
DELETE FROM CONTENTPROPERTIES 
WHERE CONTENTID IN (SELECT CONTENTID FROM IDTODELETE);
Deleting the Archiving Mails records from the BODYCONTENT table
DELETE FROM BODYCONTENT 
WHERE CONTENTID in (SELECT CONTENTID FROM IDTODELETE);
Deleting the Archiving Mails records from the NOTIFICATIONS table
DELETE FROM NOTIFICATIONS 
WHERE CONTENTID IN (SELECT CONTENTID FROM IDTODELETE);
Deleting the Archiving Mails records from the CONTENT table
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

Listing all the attachment ID of the attachments that is attached to Mail Archives
SELECT contentid FROM CONTENT
WHERE CONTENTTYPE = 'ATTACHMENT'
AND PAGEID IN (SELECT CONTENTID FROM IDTODELETE);
Delete the Mail attachment using REST API. get the <Content ID> listed from the first step.
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.

 

最終更新日 2016 年 9 月 20 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.