Import data into Snap installation from mongodump

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:

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

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

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!

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?

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:

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.

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

1 Like

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.

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

Thanks!

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