Help migrating Mastodon to Pleroma
7 votes alexgleason — 7 votes, 7 commentsSource

Hey everyone, next week I’m planning to dive head first 110% migrating Mastodon to Pleroma. Pleroma is proving to be a better platform because it can run WAY cheaper than Mastodon, which is going to be very valuable to me in the long term as I’m hosting a lot of servers with very little income. I think it will help others on the Fediverse too, making the Fediverse more accessible and cost efficient. Whatever I create, I intend to release copyleft with docs.

You guys have been a great help in the past, and I’m wondering if any of you have any experience converting data from one platform to another on live production sites.

Mapping the data will be challenging, but I can take that on. The thing I really need help with is the methodology and tooling. Let’s assume I already have a perfect understanding of both databases. What now? Should I write scripts? What language? Are there existing tools to help take on this type of database migration? Any articles you’ve read?

Even if you don’t have answers, it would help if you could help me ask the right questions. Thanks a lot!

Both databases are in Postgres. Mastodon is using Ruby on Rails, while Pleroma is using Elixir with Phoenix framework.

Well schema migrations aint fun. First of all you dont do it on the live server. Do it offline, then redirect to the new server. Second, if you can create 2 schemas in the same psql database, db.mastodon and db.pleroma, you can move data just with SQL using INSERT INTO… SELECT…

  1. export Mastodon data(json? csv?)
  2. write a script to parse the data and load it into the pleroma database

It depends on what the databases look like really. If it’s a simple one, you can add new tables and columns to the mastodon schema, copy the data and remove the old tables (or as someone else suggest, use 2 schemas). Can you just copy the data or you need to “clean” it (different types?)? Then you need to write a script, or use one of those ETL things. If it’s a super complex schema you will need patience and slow manual work. Use a database migration software to track changes (any language has one).

If pleroma has an ORM, you could adventure into using their models. Use a script to SELECT from mastodon, create a new object (User or Post or whatever) and persist it. The ORM will do the work.

Pleroma and Mastodon both have ORMs. I’ve been considering using Mastodon’s ORM to create a data export and then use Pleroma’s ORM to import it. It means there’d have to be an intermediate format, with probably a huge filesize.

It means there’d have to be an intermediate format

Does it? You could do it on the fly: select a user from mastodon, create a new user to pleroma, loop for all users.

Sorry, no experience with either mastodon or pleroma. But since you’re migrating from Postgres to Postgres you should be able to simply copy one table to another, or ALTER tables. Alternatively, Postgres has a tool called pgloader that can read data from many sources (a file or another database), change it if needed, and insert it into the target database. It uses its own syntax though, so you’ll need to do some learning.