# (Substituído) Importar arquivos MBOX (lista de emails)

**URL:** <https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233>\
**Category:** Migrating to Discourse\
**Tags:** migrations, how-to\
**Created:** [Outubro 7, 2016, 4:49pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233 "2016-10-07T16:49:38Z")\
**Posts on this page:** 13\
**Page:** 3

<div class="post-metadata">

**Author:** ![hiddeninput](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hiddeninput/32/121101_2.png) [@hiddeninput](https://meta.discourse.org/u/hiddeninput)\
**Post date:** [Abril 7, 2017, 4:51pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/41 "2017-04-07T16:51:29Z")

</div>

If one wanted to import a mailing list into an already existing discourse instance, would following the steps here result in wiping out my existing instance? And, if that’s the case, would it make sense to follow the steps here to import the archives and then use the [Topic and Category Export/Import](https://meta.discourse.org/t/topic-and-category-export-import/38930) to move the mailing list archives instead?

Thanks!

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [Abril 7, 2017, 6:04pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/42 "2017-04-07T18:04:39Z")

</div>

The way that I’d do it is to

1. back up discourse,

- freeze discourse,
- import that database on your development machine,
- import the mailing list on the dev machine,
- backup
- restore that backup on the production machine.

---

<div class="post-metadata">

**Author:** ![hiddeninput](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hiddeninput/32/121101_2.png) [@hiddeninput](https://meta.discourse.org/u/hiddeninput)\
**Post date:** [Abril 7, 2017, 6:18pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/43 "2017-04-07T18:18:22Z")

</div>

Makes sense. Thanks!

---

<div class="post-metadata">

**Author:** ![phntxx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/phntxx/32/90816_2.png) [@phntxx](https://meta.discourse.org/u/phntxx)\
**Post date:** [Agosto 16, 2017, 4:56pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/44 "2017-08-16T16:56:59Z")

</div>

I am trying to import about 142000 emails using this script, yet some emails just block everything for unknown reasons.  
Is there any way to modify the script so that emails are skipped if they take too long to process?

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [Agosto 16, 2017, 5:26pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/45 "2017-08-16T17:26:59Z")

</div>

There should be a way to modify it so that it processes or ignores those messages. Is there something about those messages that seems different?

---

<div class="post-metadata">

**Author:** ![phntxx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/phntxx/32/90816_2.png) [@phntxx](https://meta.discourse.org/u/phntxx)\
**Post date:** [Agosto 16, 2017, 5:50pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/46 "2017-08-16T17:50:07Z")

</div>

not really. I can’t see anything different about them. Might be something with CCs or so, but that’s processed in other emails just fine…

---

<div class="post-metadata">

**Author:** ![copy](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@copy](https://meta.discourse.org/u/copy)\
**Post date:** [Setembro 2, 2017, 2:16pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/47 "2017-09-02T14:16:35Z")

</div>

Is it possible to make the SQLite-to-Discourse step “verbose”? The “creating forum topics” part of the process halts reliably after a very limited number of created topics. I do not understand how to troubleshoot this part of the import.

```
importing users
Skipping 20 already imported users
Skipping 12 already imported users

creating forum topics
        2 / 192 ( 1.0%) [1093 items/min] 

```

After CTRL + V:

```
 ^C/home/discourse/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/email_reply_trimmer-0.1.7/lib/email_reply_trimmer.rb:182:in `gsub!': Interrupt
        from /home/discourse/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/email_reply_trimmer-0.1.7/lib/email_reply_trimmer.rb:182:in `block in preprocess!'
        from /home/discourse/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/email_reply_trimmer-0.1.7/lib/email_reply_trimmer.rb:181:in `each'
        from /home/discourse/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/email_reply_trimmer-0.1.7/lib/email_reply_trimmer.rb:181:in `preprocess!'
        from /home/discourse/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/email_reply_trimmer-0.1.7/lib/email_reply_trimmer.rb:33:in `trim'
        from /home/discourse/discourse/lib/email/receiver.rb:205:in `select_body'
        from script/import_scripts/mbox.rb:426:in `block (2 levels) in create_forum_topics'
        from /home/discourse/discourse/script/import_scripts/base.rb:432:in `block in create_posts'
        from /home/discourse/discourse/script/import_scripts/base.rb:431:in `each'
        from /home/discourse/discourse/script/import_scripts/base.rb:431:in `create_posts'
        from script/import_scripts/mbox.rb:419:in `block in create_forum_topics'
        from /home/discourse/discourse/script/import_scripts/base.rb:784:in `block in batches'
        from /home/discourse/discourse/script/import_scripts/base.rb:783:in `loop'
        from /home/discourse/discourse/script/import_scripts/base.rb:783:in `batches'
        from script/import_scripts/mbox.rb:413:in `create_forum_topics'
        from script/import_scripts/mbox.rb:57:in `execute'
        from /home/discourse/discourse/script/import_scripts/base.rb:45:in `perform'
        from script/import_scripts/mbox.rb:555:in `<main>'

```

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [Setembro 2, 2017, 2:24pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/48 "2017-09-02T14:24:44Z")

</div>

Sure. Just add in some

```
puts "#{somevariable}"

```

Statements at the top of that loop.

---

<div class="post-metadata">

**Author:** ![copy](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@copy](https://meta.discourse.org/u/copy)\
**Post date:** [Setembro 2, 2017, 3:53pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/49 "2017-09-02T15:53:56Z")

</div>

Thanks, that works well. Is there a place where the maximum body length of an imported message is defined?

Edit: Nevermind. I think I’ve narrowed the problem down to forward slashes (/) in the content to be imported.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [Setembro 2, 2017, 4:16pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/50 "2017-09-02T16:16:33Z")

</div>

There is a sitesetting.

If you grep other importers you can find how to set a sitesetting in the importer.

---

<div class="post-metadata">

**Author:** ![pacharanero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pacharanero/32/500583_2.png) [@pacharanero](https://meta.discourse.org/u/pacharanero)\
**Post date:** [Dezembro 17, 2017, 3:00pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/51 "2017-12-17T15:00:15Z")

</div>

@pfaffman I’m doing an import of a mbox gnu archive, the importer does all the message indexing and creates the SQLite DB index.db although there is no message content.

I suspect it will have something to do with the errors I’m getting all through the import:

`Ignoring bad email address foo.bar at example.org (Foo Bar) in`

I’ve had a look at the source around that error message, which is checking that the `from_email` matches the regex, so presumably something in those email addresses (it affects them all) is not matching.

There is a bit of email processing code in the `#extract_name` method, which is clearly designed to sort out real names in parentheses and replace `_at_` with `@`, but clearly something isn’t working as intended.

Any pointers gratefully received.

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [Outubro 31, 2018, 2:17pm UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/52 "2018-10-31T14:17:30Z")

</div>



---

<div class="post-metadata">

**Author:** ![osioke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osioke/32/238946_2.png) [@osioke](https://meta.discourse.org/u/osioke)\
**Post date:** [Julho 15, 2021, 11:05am UTC](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233/53 "2021-07-15T11:05:51Z")

</div>



[Página anterior](https://meta.discourse.org/t/superseded-import-mbox-mailing-list-files/51233.md?page=2)
