Confluence で不足している添付ファイルを解決する方法

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: 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 は除く

tip/resting Created with Sketch.

We've fixed this issue in Confluence 8.1 and later versions, so you won't need to run the Missing Attachments Script. Learn more

症状

When viewing or attempting to download attachments, you may receive a "Page not found" error. Additionally, you may receive either of the following errors in the application logs(atlassian-confluence.log)

No AttachmentData object was returned when it was expected for attachment: Attachment: fileName v.1 (123456789)

2023-03-11 13:06:30,291 WARN [http-nio-8081-exec-172] [atlassian.confluence.pages.DefaultAttachmentManager] getAttachmentData Could not find data for attachment: Attachment: image2022-1-8 11:48:26.png v.1 (873607111) mninnes - com.atlassian.confluence.pages.persistence.dao.filesystem.AttachmentDataFileSystemException: No such file for Attachment: image2022-1-8 11:48:26.png v.1 (873607111) mninnes. Were looking at /sharedhome/confluence/data/attachments/ver003/205/184/874184705/88/96/873596338/873607111/1

The key string for the second error is the 'Were looking at'.

In many cases, the attachment itself is still on disk but isn't located in the specific directory that it's expected to be in.  Often this is due to an earlier page move operation that was incomplete, and so if we can find the attachment still on disk in a different directory, we just need to relocate it to the correct subdirectory that Confluence is expecting it to be in.  As mentioned above, missing file problems are fixed in Confluence 8.1 because of the new attachment directory structure which doesn't require files to be moved if the page that they're attached to is moved)

診断

If your attachments are still somewhere in your attachment directory, this wiki will be able to help you resolve the broken attachments.  To see if your attachments exist in your attachment directory, search the folder directory for an example attachment id of a broken attachment.  For example, if your attachment has an ID of 123456789, search your confluence home directory for a folder with this name. If you get a result, it means your attachment is on disk.

On a Unix like system, you could run a command like:

find <confluence-attachment-dir> | grep 123456789

or

find . -name 123456789

On a Windows system, you could use a command like:

dir <confluence-attachment-dir> /s | findstr 123456789

データベースを基盤とする添付ファイル ストレージを使っている場合...

「ソリューション - データベースを基盤とする添付ファイル ストレージ」のセクションをご確認ください。 

If you're hitting into missing attachments issue after performing Space Import

You should not proceed with this document, as when importing a Space - new IDs are generated for Space IDs, Page IDs and Attachment IDs, and the script would not work well. Instead, please contact Atlassian Support for further assistance.

ディスクで添付ファイル ID を検索しても結果が返されない場合...

このドキュメントの手順には従わず、不足している attachments ディレクトリをバックアップから復元する必要があります。ファイルをディスクに復元したあとに、引き続き、不足している添付ファイルを復元する必要がある場合があります。

ソリューション #1 - ファイルシステムを基盤とするストレージおよび Confluence 3.0 以降

tip/resting Created with Sketch.

ディスク上に引き続き存在する、不足している添付ファイルを修正するスクリプトを用意しました。

Missing Attachments Script をダウンロードし、READ.MD ファイルの手順に従う

(info) Please ensure that at minimum Python 2.7 is installed, Python 3.5+ is recommended. Confluence must also be stopped whilst this script runs to ensure that there's no concurrent file operations occurring within the attachments directory.

It's recommended to run this from a Confluence node but you may also run the script from a local machine. The script requires access to the attachments directory from wherever you choose to run the script from, so ideally you should ensure that the OS user account running this script is the same OS user account which runs the Confluence process (preferred), or an account with equivalent rights/permissions.

(warning) 始める前に、attachments ディレクトリの完全なバックアップを作成済みであることをご確認ください。復元を本番環境に適用する前にテスト サーバーでのテストを行う必要があります。

引き続き、ページで直接、あるいは添付ファイルリンクで添付ファイルをプレビューできないが、ファイルのダウンロードは行える場合、次の手順を行います。

  • ブラウザ キャッシュをクリアし、ブラウザでページのハード リロードを行います。
  • 匿名モードがトラブルシューティングに役立つ可能性があります。

ソリューション #2 - データベースを基盤とする添付ファイルストレージの場合

データベースを基盤とする添付ファイル ストレージは Confluence 5.6 以降で廃止予定になっていることにご注意ください。新しいインスタンスでデータベースを基盤とする添付ファイル ストレージにスワップすることはできません。データベース基盤の添付ファイル ストレージを使っている場合、ファイル システムを基盤とするストレージに移行することをおすすめします。

不足している添付ファイルのレポートを生成するために利用できるツールはありません。しかしながら、添付ファイルが不足していることを確認した場合、最近の SQL バックアップから添付ファイルを attachmentdata テーブルに復元できます。

添付ファイルを復元できるような Confluence バックアップをお持ちではない場合、データベースから添付ファイルのレコードを削除できます。

データベース基盤のストレージを使っている場合に添付ファイルを削除する方法

次の SQL コマンドを実行します。

Confluence 5.7 以降
DELETE FROM CONTENTPROPERTIES WHERE CONTENTID IN (SELECT CONTENTID FROM CONTENT WHERE CONTENTTYPE = 'ATTACHMENT' and TITLE LIKE '%<ATTACHMENT_NAME>%');
DELETE FROM CONTENT WHERE CONTENTTYPE = 'ATTACHMENT' AND TITLE LIKE '%<ATTACHMENT_NAME>%';
Confluence 5.6.x 以前
DELETE FROM attachmentdata WHERE attachmentid IN (SELECT attachmentid FROM ATTACHMENTS WHERE TITLE LIKE '%<ATTACHMENT_NAME>%' );
DELETE FROM ATTACHMENTS WHERE TITLE LIKE '%<ATTACHMENTNAME>%'

これらのクエリで返される結果では、添付ファイルが不足しているかどうかはわかりません。

最終更新日: 2023 年 10 月 30 日

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

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