# How to import only last two years of topics and posts (phpbb3)

**URL:** https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962
**Category:** Self-hosting
**Created:** [8 Dezembro , 2016 14:22 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962 "2016-12-08T14:22:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [8 Dezembro , 2016 14:22 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/1 "2016-12-08T14:22:52Z")

</div>

Hi! We’re in a process to make a move from phpbb3 to Discourse. We would like to not import older data and go for example with posts starting from year 2014 or 2015. How can this be done? Has anyone experience with such thing?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [8 Dezembro , 2016 14:26 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/2 "2016-12-08T14:26:57Z")

</div>

Either use a dump of your phpBB3 database where you removed all the old content or modify the import script to add a condition in the SQL queries to only retrieve new content.

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [8 Dezembro , 2016 14:30 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/3 "2016-12-08T14:30:31Z")

</div>

I was hoping for more specific hint… preferably something simple and elegant and what works (something from personal experience maybe) 🙂

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [8 Dezembro , 2016 14:31 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/4 "2016-12-08T14:31:11Z")

</div>

Both these solutions work and are from my personal experience 😉

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [8 Dezembro , 2016 14:31 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/5 "2016-12-08T14:31:56Z")

</div>

but unfortunately too darn unspecific 😛

---

<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: [8 Dezembro , 2016 14:46 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/6 "2016-12-08T14:46:53Z")

</div>

I have added code to several importers that does just that. Search the import scripts for IMPORT\_AFTER for several examples.

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [8 Dezembro , 2016 19:31 UTC](https://meta.discourse.org/t/how-to-import-only-last-two-years-of-topics-and-posts-phpbb3/53962/7 "2016-12-08T19:31:50Z")

</div>

What if we use “last\_post\_id” and set it to something from which we know is the last post we don’t want to import? Could it work?

Here:

> <https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/script/import_scripts/phpbb3/importer.rb#L106>
