# Import data into Snap installation from mongodump

**URL:** https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428
**Category:** Community Support
**Created:** [October 19, 2021, 6:26pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428 "2021-10-19T18:26:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://forums.rocket.chat/u/Jasper)
#### Post date: [October 19, 2021, 6:26pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/1 "2021-10-19T18:26:16Z")

</div>

### Description

I’m trying to move from an old version 0.46.0 to the the latest snap version. I tried dumping my old data with mongodump, compressing the dump to `rocketchat_backup_20211019.1117.tar.gz`, moving the archived dump to `/var/snap/rocketchat-server/common/backup/`

Finally, I run the restor command below:

```bash
user@host:~$ sudo snap run rocketchat-server.restoredb /var/snap/rocketchat-server/common/backup/rocketchat_backup_20211019.1117.tar.gz
WARNING: cgroup v2 is not fully supported yet, proceeding with partial confinement
***ATTENTION***
* Your current database WILL BE DROPPED prior to the restore!
* Do you want to continue?
1) Yes
2) No
#? 1
[*] Extracting backup file...
ls: cannot access '/var/snap/rocketchat-server/common/restore/dump/parties': No such file or directory
[!] No restore data found within /var/snap/rocketchat-server/common/restore/dump/parties!
[*] Check /var/snap/rocketchat-server/common/restore/restore_20211019.1120.log for details.
[-] Restore aborted!

```

If I can’t do a restore using `restoredb` due to my data dump coming from a really old version, can I manually import user, message, and room data manually flat files using mongoimport?

### Server Setup Information

- Version of Rocket.Chat Server: latest snap
- Operating System: Debian
- Deployment Method: snap
- Number of Running Instances: 1

### Any additional Information

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [October 19, 2021, 6:53pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/2 "2021-10-19T18:53:12Z")

</div>

Hi Jasper!

Upgrading from 0.46.0 to the latest version is a huge leap and a **big no no**.

I would try to create a docker environment with 0.46.0 first, and import your data there.

Then, you go migrating, for each major version at it’s least minor all the way to the latest inside that major.

Here you can have the versions more easily, considering the plan below:  
[https://hub.docker.com/\_/rocket-chat?tab=tags&page=6](https://hub.docker.com/_/rocket-chat?tab=tags&page=6)

I would go:  
0.46.0 → 0.74 → 1.0 → 1.3.2 → 2.0 → 2.4.9 → 3.0.3 → 3.18.2 → 4.0.3

Of course, **always do backups and test it first at your staging environment.**

Let me know how it went! THanks!

---

<div class="post-metadata">

### Author: ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://forums.rocket.chat/u/Jasper)
#### Post date: [October 19, 2021, 6:56pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/3 "2021-10-19T18:56:40Z")

</div>

Thanks for the info on the upgrade path! We have a very small team (\< 10 members). I might be interested in dumping users, messages, and rooms and importing them with mongoimport. Thoughts on the feasibility of this type of import?

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [October 19, 2021, 7:23pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/4 "2021-10-19T19:23:14Z")

</div>

Not sure if that would work without the proper migration path.

You are basically exporting the database into csv, or other, and trying to import to the latest version, not caring with the schema migration at all.

And there was a lot from where you are to the latest version.

You can, however, use the import from the rocketchat itself, as described here:

> **[CSV](https://docs.rocket.chat/guides/administration/admin-panel/import/csv)**

But you will have to export the data, and do some work in order to make it follow the pattern described above.

With the proper CSV at hands, you can import it at the latest.

---

<div class="post-metadata">

### Author: ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://forums.rocket.chat/u/Jasper)
#### Post date: [October 19, 2021, 7:34pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/5 "2021-10-19T19:34:02Z")

</div>

Perfect! I’m going to try importing this way. Thanks

---

<div class="post-metadata">

### Author: ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://forums.rocket.chat/u/Jasper)
#### Post date: [October 22, 2021, 7:26pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/6 "2021-10-22T19:26:39Z")

</div>

I couldn’t get this to work, but I was able to import the data with:

1. `mongoexport`
2. change user ids and roomids in the messages from the old ids to the new ones (`sed 's/$OLD_ID/$NEW_ID/g'`)
3. changing `{ts: {$date: "2021-01-01T00:00:00.000Z"}}` to `{ts: ISODate("2021-01-01T00:00:00.000Z")}`
4. adding `db.rockechat_message.import([` to top of the file
5. Running `load("/snap/rocketchat-server/msgs.js")` from the mongo console

without step 3 the data would load but the messages wouldn’t appear in the timeline.

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [October 22, 2021, 7:28pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/7 "2021-10-22T19:28:36Z")

</div>

Wow. Nice solution! Thanks for sharing!! I’ll mark it as a solution for future reference, ok?

Thanks!

---

<div class="post-metadata">

### Author: ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://forums.rocket.chat/u/Jasper)
#### Post date: [October 22, 2021, 7:29pm UTC](https://forums.rocket.chat/t/import-data-into-snap-installation-from-mongodump/12428/8 "2021-10-22T19:29:41Z")

</div>

Sounds good. Thanks for all your help! I pointed me in the right direction
