Migrating jobs to a new database (Mongo -> Postgres)


#1

We are currently looking into migrating from MongoDB to Postgres. While setting up a new project is easy, I was wondering if there is some way of migrating existing scheduled jobs to the new database. Searching for anything relevant on Google just takes me to this page: https://docs.hangfire.io/en/latest/configuration/using-sql-server.html

I tried setting up two storage options (Mongo, then Postgres) for Hangfire, hoping that it would duplicate the jobs to the new db, but it just ignores the first one. Has anyone changed databases before and has any tips for how I could do this?


#2

I think the idea is that you don’t migrate the jobs, you run the two storage options simultaneously, dequeuing Jobs off both but only queuing Jobs up to the new storage. Eventually you’d have no Jobs left in the old storage and could decommission it.

Sounds pretty painless if your migration strategy will allow this more gradual approach.