Mailing リストを Discourse へ移行する (mbox、Listserv、Google Groups など)

This guide is for you if you want to migrate a mailing list to Discourse.
It also contains instructions for importing messages from image Google Groups.

1. Importing using Docker container

This is the recommended way for importing content from your mailing lists into Discourse.

1.1. Installing Discourse

:bulb: The import script most likely won’t work on systems with less than 4GB of RAM. Recommended are 8GB of RAM or more. You can scale back the RAM usage after the import if you like.

Install Discourse by following the official installation guide. Afterwards it’s a good idea to go to the Admin section and configure a few settings:

  • Enable login_required if imported topics shouldn’t be visible to the public

  • Enable hide_user_profiles_from_public if user profiles shouldn’t be visible to the public.

  • Disable download_remote_images_to_local if you don’t want Discourse to download images embedded in posts.

  • Enable disable_edit_notifications if you enabled download_remote_images_to_local and don’t want your users to get lots of notifications about posts edited by the system user.

  • Change the value of slug_generation_method if most of the topic titles use characters which shouldn’t be mapped to ASCII (e.g. Arabic). See this post for more information.

:bangbang: The following steps assume that you installed Discourse on Ubuntu and that you are connected to the machine via SSH or have direct access to the machine’s terminal.

1.2. Preparing the Docker container

Copy the container configuration file app.yml to import.yml and edit it with your favorite editor.

cd /var/discourse
cp containers/app.yml containers/import.yml
nano containers/import.yml
Regular import

Add - "templates/import/mbox.template.yml" to the list of templates. Afterwards it should look something like this:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"
  - "templates/import/mbox.template.yml"

That’s it. You can save the file, close the editor and build the container.

Google Groups import

You need to add two entries to the list of templates:

  - "templates/import/chrome-dep.template.yml"
  - "templates/import/mbox.template.yml"

Afterwards it should look something like this:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"
  - "templates/import/chrome-dep.template.yml"
  - "templates/import/mbox.template.yml"

That’s it. You can save the file, close the editor and build the container.

/var/discourse/launcher stop app
/var/discourse/launcher rebuild import

Building the container creates an import directory within the container’s shared directory. It looks like this:

/var/discourse/shared/standalone/import
├── data
└── settings.yml

1.3. Downloading messages from Google Groups (optional)

You can skip this step unless you want to migrate from image Google Groups.

Instructions for Google Groups

1.3.1. Preparation

:warning: Make sure you don’t have any pinned posts in your group, otherwise the crawler might fail to download some or all messages.

:warning: Make sure the group settings allow posting, otherwise you might see “Failed to scrape message” error messages. It might take a couple of minutes before the scraping works when you changed those settings recently.

Google account: You need a Google account that has the Manager or Owner role for your Google Group, otherwise the downloaded messages will contain censored email addresses.

Group name: You can find the group name by visiting your Google Group and looking at the browser’s address bar. image

Domain name: The URL might look a little bit differently if you are a G Suite customer. You need to know the domain name if the URL contains something like example.com. image

1.3.2 Cookies :cookie:

In order to download messages, the crawler needs to have access to a Google account that has the owner role for your group. Please visit https://myaccount.google.com/ in your browser and sign in if you aren’t already logged in. Then use a browser extension of your choice to export your cookies for google.com in a file named cookies.txt.

The recommended browser extensions is Export Cookies for Mozilla Firefox.

Upload the cookies.txt file to your server and save it within the /var/discourse/shared/standalone/import directory.

1.3.3. Download messages

:bulb: Tip: It’s a good idea to download messages inside a tmux or screen session, so that you can reconnect to the session in case of SSH connection loss.

Let’s start by entering the Docker container.

/var/discourse/launcher enter import

Replace the <group_name> (and if applicable, the <domain_name>) placeholders within the following command with the group name and domain name from step 1.3.1 and execute it inside the Docker container in order to start the download of messages.

If you didn’t find a domain name in step 1.3.1, this is the command for you:

script/import_scripts/google_groups.rb -g <group_name>

Or, if you found a domain name in step 1.3.1, use this command instead:

script/import_scripts/google_groups.rb -g <group_name> -d <domain_name>

Downloading all messages can take a long time. It mostly depends on the number of topics in your Google Group. The script will show you a message like this when it’s finished: Done (00h 26min 52sec)

:bulb: Tip: You can abort the download anytime you want by pressing Ctrl+C
When you restart the download it will continue where it left off.

1.4. Configuring the importer

You can configure the importer by editing the example settings.yml file that has been copied into the import directory.

nano /var/discourse/shared/standalone/import/settings.yml

The settings file comes with sensible defaults, but here are a few tips anyway:

  • The settings file contains multiple examples on how to split data files:

    • mbox files usually are separated by a From header. Choose a regular expression that works for your files.

    • If each of your files contains only one message, set the split_regex to an empty string. This also applies to imports from image Google Groups.

    • There’s also an example for files from the popular Listserv mailing list software.

  • prefer_html allows you to configure if the import should use the HTML part of emails when it exists. You should choose what suits you best – it heavily depends on the emails sent to your mailing list.

  • By default each user imported from the mailing list is created as staged user. You can disable that behaviour by setting staged to false.

  • If your emails do not contain a Message-ID header (like messages stored by Listserv), you should enable the group_messages_by_subject setting.

1.5. Prepare files

Each subdirectory of /var/discourse/shared/standalone/import/data gets imported as its own category and each directory should contain the data files you want to import. The file names of those do not matter.

Example: The import directory should look like this if you want to import two mailing lists with multiple mbox files:

/var/discourse/shared/standalone/import
├── data
│   ├── list 1
│   │   ├── foo
│   │   ├── bar
│   ├── list 2
│   │   ├── 2017-12.mbox
│   │   ├── 2018-01.mbox
└── settings.yml

1.6. Executing the import script

:bulb: Tip: It’s a good idea to start the import inside a tmux or screen session, so that you can reconnect to the session in case of SSH connection loss.

Let’s start the import by entering the Docker container and launching the import script inside the Docker container.

/var/discourse/launcher enter import
import_mbox.sh # inside the Docker container

Depending on the size of your mailing lists it’s now time for some :coffee: or :sleeping:
The import script will show you a message like this when it’s finished: Done (00h 26min 52sec)

:bulb: Tip: You can abort the import anytime you want by pressing Ctrl+C
When you restart the import it will continue where it left off.

You can exit and stop the Docker container after the import has finished.

exit # inside the Docker container
/var/discourse/launcher stop import

1.7. Starting Discourse

Let’s start the app container and take a look at the imported data.

/var/discourse/launcher start app

Discourse will start and Sidekiq will begin post-processing all the imported posts. This can take a considerate amount of time. You can watch the progress by logging in as admin and visiting http://discourse.example.com/sidekiq

1.8. Clean up

So, you are satisfied with the result of the import and want to free some disk space? The following commands will delete the Docker container used for importing as well as all the files used during the import.

/var/discourse/launcher destroy import
rm /var/discourse/containers/import.yml
rm -R /var/discourse/shared/standalone/import

1.9. The End

Now it’s time to celebrate and enjoy your new Discourse instance! :tada:

2. FAQ

2.1. How can I remove list names (e.g. [Foo]) from topic titles during the import?

You can use an empty tag to remove one or more prefixes from topic titles. The settings file contains an example.

2.2 How can I prevent the import script from detecting messages as already being imported?

:warning: The following steps will reset your Discourse forum to the initial state! You will need to start from scratch.

The following commands will stop the container, delete everything except the mbox files and the importer configuration and restart the container.

Commands
cd /var/discourse

./launcher stop app
./launcher stop import

rm -r ./shared/standalone/!(import)
rm ./shared/standalone/import/data/index.db

./launcher rebuild import

./launcher enter import
import_mbox.sh # inside the Docker container

2.3 How can I manipulate messages before they are imported into Discourse?

Enable index_only in settings.yml and take a look at the index.db (a SQLite database) before you run the actual import.

You can use SQL to update missing values in the database if you want. That way you don’t need to reindex any messages. The script uses only data from the index.db during the import phase. Simply disable the index_only option when you are done and rerun the importer. It will skip the indexing if none of the mbox files were changed, recalculate the content of the user and email_order tables and start the actual import process.

2.4 How can I find messages which cause problems during the import?

You can split mbox files into individual files to make it easier to find offending emails.

Commands
apt install procmail;
export FILENO=0000;
formail -ds sh -c 'cat &gt; split/msg.$FILENO' < mbox;

2.5 I have already imported a group. How can I import another group?

Create a new directory in the import/data directory and restart the import script.

2.6 I don’t have access to Mailman archives in mbox format? Is there any other way to get them?

You could give this script a try.

Last edited by @JammyDodger 2024-05-27T14:56:11Z

Check documentPerform check on document:
「いいね!」 30

@gerhard - I was able to migrate an mbox archive of 22,000 messages using this script on a Digital Ocean droplet with only 1GB RAM. No problems. Thank you for the write-up of instructions. Everything worked great. The only mistake I made on my first attempt was trying to name the /var/discourse/shared/standalone/import/data/X subfolder using a new category I created before running the script. That caused the import to place these messages into the Uncategorized category. On second attempt, I deleted the new category and tried again. This created the category name for me and placed the messages into the proper category automatically.

「いいね!」 6

このガイドをありがとうございます。

Google グループのインポートを試みていますが、import_mbox.sh を実行すると以下のエラーが発生します。

The mbox import is starting...

Traceback (most recent call last):
5: from script/import_scripts/mbox.rb:9:in `<main>'
4: from script/import_scripts/mbox.rb:10:in `<module:ImportScripts>'
3: from script/import_scripts/mbox.rb:13:in `<module:Mbox>'
2: from /var/www/discourse/script/import_scripts/mbox/support/settings.rb:9:in `load'
1: from /var/www/discourse/script/import_scripts/mbox/support/settings.rb:9:in `new'

/var/www/discourse/script/import_scripts/mbox/support/settings.rb:42:in `initialize': undefined method `each' for nil:NilClass (NoMethodError)

ただし、/var/discourse/shared/standalone/import/data/Foo 内のすべてのファイルは mbox 形式ではなく .eml 形式です。これは問題になりますか?

ありがとうございます!

インポートスクリプトの最新バージョンでその問題が修正されました。代替案として、設定ファイル を更新してください。最近いくつかの変更が行われています。

「いいね!」 5

どうもありがとうございます。インポートスクリプトの更新方法についてアドバイスをお願いします。

インポートスクリプトを更新するだけで十分でしょうか、それともガイドの他の手順(どの手順ですか?)をやり直す必要がありますか?それらが見つからず、どのように更新すればよいのかわかりません。

ご提案いただいた代替手段として設定ファイルは更新しましたが、同じ問題が発生しています。

よろしくお願いいたします。

インポートスクリプトおよびそれに関連するすべてのものを更新するには、/var/discourse/launcher rebuild importを実行してください。

「いいね!」 4

ありがとうございます。

import_mbox.sh を実行している間、ほぼすべてのメッセージが以下のようなメッセージでスキップされています。

script/import_scripts/mbox.rb:12:in `<module:Mbox>'

script/import_scripts/mbox.rb:10:in `<module:ImportScripts>'

script/import_scripts/mbox.rb:9:in `<main>'

41 / 215 ( 19.1%) [59096 items/min] 36a37072-e5b6-4009-878f-f0824e40eac6@googlegroups.com の投稿のマッピングに失敗しました

undefined method `each' for nil:NilClass

/var/www/discourse/script/import_scripts/mbox/importer.rb:179:in `block in remove_tags!'

/var/www/discourse/script/import_scripts/mbox/importer.rb:176:in `loop'

/var/www/discourse/script/import_scripts/mbox/importer.rb:176:in `remove_tags!'

/var/www/discourse/script/import_scripts/mbox/importer.rb:150:in `map_first_post'

/var/www/discourse/script/import_scripts/mbox/importer.rb:104:in `block (2 levels) in import_posts'

/var/www/discourse/script/import_scripts/base.rb:503:in `block in create_posts'

/var/www/discourse/script/import_scripts/base.rb:502:in `each'

/var/www/discourse/script/import_scripts/base.rb:502:in `create_posts'

/var/www/discourse/script/import_scripts/mbox/importer.rb:98:in `block in import_posts'

/var/www/discourse/script/import_scripts/base.rb:882:in `block in batches'

/var/www/discourse/script/import_scripts/base.rb:881:in `loop'

/var/www/discourse/script/import_scripts/base.rb:881:in `batches'

/var/www/discourse/script/import_scripts/mbox/importer.rb:84:in `batches'

/var/www/discourse/script/import_scripts/mbox/importer.rb:92:in `import_posts'

/var/www/discourse/script/import_scripts/mbox/importer.rb:36:in `execute'

/var/www/discourse/script/import_scripts/base.rb:47:in `perform'

さらに以下のように表示されます。

60 / 215 ( 27.9%) [58321 items/min] 親メッセージ 1b46f337-95a3-4b4a-a14a-689636941580@googlegroups.com が存在しません。5634208e-e6df-4bd8-b361-0735f73fe554@googlegroups.com をスキップします:

この原因は何でしょうか?ありがとうございます。

問題は修正されるはずです。インポートコンテナをもう一度再ビルドしてください。

「いいね!」 6

最高、完璧に動きました。:pray: ご支援ありがとうございます。

「いいね!」 5

Google グループのダウンロードを試みていますが、以下のエラーが表示されます。

Failed to login. Please check the content of your cookies.txt

推奨されている Firefox 拡張機能を使ってクッキーをダウンロードしました。昨日一度、今日もう一度試みました。ファイル名を誤った名前に変更して「not found」エラーが出ることを確認し、ファイルが正しく読み込まれていることを検証しました。Google 関連のクッキーだけでなく、すべてのクッキーをダウンロードしました。ログアウトして再度ログインし、クッキーを再ダウンロードしました。

「manage group」オプションが表示されているため、管理者としてログインできていることは確認しています。

グループ名が正しいか、コピー&ペーストで確認し、ドメイン名形式ではなくグループ名形式であることを三度確認しました。

何か不具合があるのか、それとも私の環境の問題でしょうか?

@gerhard、すみませんが、デバッグ方法について簡単なご提案をいただけませんか?もしかすると、ログインエンドポイントが変更されたのかもしれません。

編集:原因が見つかりました。すぐに PR を提出します。ログイン用のエンドポイントが変更されており、新しいエンドポイントを推測できました。:slight_smile:

「いいね!」 1

Yahoo グループから mbox ファイルをインポートしようとしている初心者です。これらの手順を何度か試しましたが、毎回同じエラーメッセージが表示されます。他の人は成功しているようなので、おそらく初心者のミスだと思われます。エラーは、split_regex: "^From .+@.+" がファイルを分割するためのメールキーを見つけられていないことを示しているようですが、テキストエディタで正規表現をテストしたところ、期待通りに動作しました。インポートファイルの 2 行目は Message-ID: <35690.0.1.959300741@eGroups.com> のような形式です。
何かアイデアはありますか?ご協力ありがとうございます…

mbox インポートを開始しています...

Traceback (most recent call last):
	12: from script/import_scripts/mbox.rb:9:in `<main>'
	11: from script/import_scripts/mbox.rb:10:in `<module:ImportScripts>'
	10: from script/import_scripts/mbox.rb:12:in `<module:Mbox>'
	 9: from script/import_scripts/mbox.rb:12:in `new'
	 8: from /var/www/discourse/script/import_scripts/mbox/importer.rb:11:in `initialize'
	 7: from /var/www/discourse/script/import_scripts/mbox/support/settings.rb:8:in `load'
	 6: from /usr/local/lib/ruby/2.6.0/psych.rb:577:in `load_file'
	 5: from /usr/local/lib/ruby/2.6.0/psych.rb:577:in `open'
	 4: from /usr/local/lib/ruby/2.6.0/psych.rb:578:in `block in load_file'
	 3: from /usr/local/lib/ruby/2.6.0/psych.rb:277:in `load'
	 2: from /usr/local/lib/ruby/2.6.0/psych.rb:390:in `parse'
	 1: from /usr/local/lib/ruby/2.6.0/psych.rb:456:in `parse_stream'
/usr/local/lib/ruby/2.6.0/psych.rb:456:in `parse': (/shared/import/settings.yml): did not find expected key while parsing a block mapping at line 2 column 1 (Psych::SyntaxError)

settings.yml ファイルにエラーがあるようです。設定を http://www.yamllint.com/ で検証することをお勧めします。

「いいね!」 3

@gerhard ありがとう… sigh… その問題に気づくべきだった。Ruby での初めての経験だ。さて、少しは近づいたと思うが、別のエラーが出ている(以下参照)。インポートスクリプトが現在、グループなどを読み込んでいるので、この新しいエラーは初期の問題を過ぎたところにあると推測する。また、参照されている db ファイルはインポートスクリプトによって作成される import/index.db だと想定している(ただし、まだ作成されていないようだ)。

mbox のインポートを開始しています...

既存のグループを読み込んでいます...
既存のユーザーを読み込んでいます...
既存のカテゴリを読み込んでいます...
既存の投稿を読み込んでいます...
既存のトピックを読み込んでいます...
トレースバック(最新の呼び出しから):
	9: from script/import_scripts/mbox.rb:9:in `<main>'
	8: from script/import_scripts/mbox.rb:10:in `<module:ImportScripts>'
	7: from script/import_scripts/mbox.rb:12:in `<module:Mbox>'
	6: from script/import_scripts/mbox.rb:12:in `new'
	5: from /var/www/discourse/script/import_scripts/mbox/importer.rb:14:in `initialize'
	4: from /var/www/discourse/script/import_scripts/mbox/importer.rb:14:in `new'
	3: from /var/www/discourse/script/import_scripts/mbox/support/database.rb:10:in `initialize'
	2: from /var/www/discourse/script/import_scripts/mbox/support/database.rb:10:in `new'
	1: from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:89:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:89:in `open_v2': unable to open database file (SQLite3::CantOpenException)
「いいね!」 1

SYSTEM の制限によりコメントを編集できないため、代わりにこの返信を送信します。

編集:一連の対応を完了するため…私の Yahoo グループのインポートが、少なくとも 9951 件のメールをインデックス化できる段階まで機能するようになりました。完全なインポートはまだ完了していないため、引き続き報告します。settings.yml を何度も編集しましたが、現在は突然動作し始めた元の設定に戻っています。構文エラーは発生していません。なぜ一貫性のないエラーメッセージが複数表示されたのか理解できません。settings.yml の元の構文エラーも再び謎です。上記のエラーメッセージは私には意味がわかりません…ため息。

「いいね!」 1

@gerhard. 同じことをより簡単な方法で見つけたと思います。あなたのガイドと同じ結果が得られますが、技術的な知識もサーバーへの管理者権限も不要です。ご意見をお聞かせください。

概要

実質的にはメーリングリストを設定し、過去の会話を順番に送信するためにメールアーカイブを使用します。これらのメールは転送されますが、メールクライアントの「転送」ボタンのようにヘッダーを上書きしたりインデントを崩したりするものではありません。私たちがやりたいのは、Discourse に最初に送信されたかのように再送信(リメール)することです。

要件と前提条件

  • 過去のメールのやり取りへのアクセス: これをすべてメールクライアントに保存しており、転送をボランティアで行える人 – その人を「ジョン・ドウ」と呼びましょう。

  • 時間: メール転送は非常に遅くなりますが、Discourse が処理できる範囲内です(アーカイブのサイズによりますが、コンピューターを稼働させて数日かかるかもしれません)。

  • Thunderbird クライアント: ここでは、ジョン・ドウがメールクライアントとして「Thunderbird」を使用していることを前提としています。他のクライアントでも可能かもしれませんが、確認していません。

以下のガイドでは、2 つのメールアドレスをプレースホルダーとして使用しています。これらを実際のアドレスに置き換えてください。

:incoming_envelope: johndoe@example.com ジョン・ドウのメール(この人がメーリングリストのアーカイブ全体を転送します)

:postbox: discourse+mailinglist-3@discoursemail.com メーリングリストのカテゴリにメールを転送するための Discourse メール(設定 1. を参照)

手順

手順の概要は以下の通りです。

  1. Mirroring a read-only mailing list in Discourse のガイドに従って、メーリングリストのミラーを作成します。

    : これは今後のメーリングリストのみをミラーリングします。過去の会話は依然として見逃してしまいます。それがこのガイドの残りの部分の目的です。

  2. Discourse がメールを転送する方法を変更します(実際にはこれが必須かどうかはわかりません
    forwarded_behavior

  3. カテゴリの設定を編集し、カスタム受信メールアドレス:の設定で、既存の内容の末尾に |johndoe@example.com を追加します。

    ここでのパイプ記号は , のように機能し、johndoe@example.com もそのカテゴリに送信できることを意味します

  4. ジョン・ドウは Thunderbird に拡張機能 Mail Redirect をインストールします。

    これは通常のメール転送ではないためです。これにより、メールがジョン・ドウのものではなく、最初に Discourse のメールアドレス宛に送信されたかのように送信されます

  5. ジョン・ドウは拡張機能の設定に移動し、以下の値を 1 に設定します(デフォルトは 5)
    mail_redirect

    これにより、返信が順番に到着することが保証されます。そうしないと、Discourse は返信が連鎖していることに気づくのが遅く、各返信に対して新しいトピックを作成してしまいます – ただし、転送プロセスは非常に遅くなります

  6. ジョン・ドウはメーリングリストの過去のメールをすべて選択し、右クリックして リダイレクト をクリックします。新しいウィンドウが開くので、Resend-todiscourse+mailinglist-3@discoursemail.com を追加します。

これにより、ジョン・ドウのメールクライアントはゆっくりとメールアーカイブを Discourse に送信し始めます。しばらくしてから確認して、Discourse カテゴリが懐かしい古い会話で埋め尽くされているか確認してください。

クリーンアップ

  • カテゴリの カスタム受信メールアドレス:設定から ジョン・ドウのメールを削除 します(| の削除も忘れずに)

  • Mail Redirect 拡張機能をアンインストール – 二度と必要ないか、少なくとも SMTP 接続数を 5 に戻してください。

「いいね!」 5

既存の Discourse インスタンスに Mailman リストを移行しようとしています。対応するカテゴリの権限を設定する必要がある、いくつかのプライベートリストが含まれています。インポート前にそれらのカテゴリを作成すると、プライベートリストのすべての投稿が「未分類」に追加されてしまい(つまり、自動的に公開されてしまいます)。

したがって、2 つの代替案に関する質問があります。

  • インポート前に、インポートされたメーリングリストの権限を設定する方法はありますか(もし管理者のみが閲覧可能であれば、私たちの目的はすでに達成されます)?
  • 既存のカテゴリ(事前に設定された権限を持つ)にメーリングリストを追加する方法はありますか?
「いいね!」 3

私のDiscourseはYahooグループの続きであり、そのYahooグループ自体もAOLのリストサーブの続きです。昨秋、Yahooの大規模な削除に対処するため、Yahooグループの.mboxアーカイブをダウンロードし、これらの手順に従ってメッセージをインポートしました。現在、AOLのリストサーブの部分的なアーカイブを取得したため、これらのメッセージもインポートしたいと考えています。

簡単ですよね?import/data/fooを作成し、そこにメッセージを配置して、インポートスクリプトを実行するだけです。しかし、後で完全な(またはより完全な)アーカイブを取得できた場合、どうなるのか気になります。それらのファイルをimport/data/fooに追加して、インポートスクリプトを再度実行すれば、同じカテゴリに新しいメッセージが追加されるでしょうか?

  • 重複排除は行われるでしょうか?それとも、両方のアーカイブに含まれていたメッセージが複数回表示されるのでしょうか?
    • もし一方、もう一方、または両方のアーカイブにメッセージIDヘッダーが存在しない場合、この答えは変わるでしょうか?
  • 同じカテゴリへの新しいインポートは、既存のメッセージを上書きするでしょうか?
  • 私のユーザーのほとんどはメーリングリストモードを使用しています。何百、あるいは何千もの通知でユーザーをスパムしたくないだけでなく、高価なMailgunの請求額が増えるのも避けたいため、インポート中はサイト全体でメールを無効にすべきだと考えています。
「いいね!」 3

残念ながら、それは不可能です。

はい、インポートスクリプトをだまして既存のカテゴリを再利用させることができます。

./launcher enter app
rails c

# URLに表示されているカテゴリIDを使用します。例えば
# カテゴリのパスが /c/howto/devs/56 の場合、IDは56です
category = Category.find(56)

# mbox ファイルが保存されているディレクトリ名を使用します。例えば、
# ファイルが import/data/foo に保存されている場合、ディレクトリ名は "foo" を使用します。
category.custom_fields["import_id"] = "directory_name"
category.save!

それは予想外ですね。そのような現象を見たことはありませんが、デフォルト以外の権限を持つ既存のカテゴリへのインポートを試したこともありません。

うまくいかない場合は、フォーラムに告知を投稿し、サイトを読み取り専用モードに切り替えてバックアップを作成し、別のサーバーでバックアップを復元してインポートを実行し、カテゴリの権限を設定してから、再度バックアップを作成して本番サイトへ復元することをお勧めします。

「いいね!」 3

はい、可能です。以前にインポートされたデータを参照したり、生成されたメッセージ ID を変更したりする必要がある場合に備えて、import/data/index.db ファイルを保持しておくことをお勧めします。

はい、Message-ID ヘッダーが同じであれば、すでにインポート済みのメッセージは再インポートされません。ただし、Message-ID ヘッダーが片方のアーカイブのみに欠落している場合は困ってしまいます。ヘッダーがない場合はメッセージの MD5 ハッシュを使用します。両方のメッセージが同じ Message-ID ヘッダーを持つか、同じ MD5 ハッシュを生成するようにする必要があります。

いいえ、上書きされません。

インポート中は、すべての送信メールが無効になります。

「いいね!」 3

はい、インポートスクリプトを既存のカテゴリを再利用するように騙すことができます。

なるほど、結局私たちは基本的にそれをやりました(代わりに Category.find_by_name() を使いましたが、それは単に表現の違いでしょう)。正しい方法を選べてよかったですね :wink: 。ありがとうございます!

「いいね!」 3