Can we do a mongo 4.2 dump and then restore to mongo 6.0.3 directly

Welcome to the MongoDB community @Daniel_Wan !

The recommended (and most throughly tested) upgrade path is to do in-place upgrades through successive major releases of MongoDB ( 4.2 → 4.4 → 5.0 → 6.0 as you have suggested).

However, if you want to fast forward through several major release upgrades and downtime is acceptable, you can consider using mongodump and mongorestore to go directly from your current release to the latest. As with any major system change, I recommend testing this in a representative staging or QA environment before upgrading in production. You may discover a few issues that need to be corrected in the source data (for example, stricter validation of collection options), however I believe these should all be fixable.

Please also see this response including alternative approaches such as automation: Replace mongodb binaries all at once? - #3 by Stennie_X.

4.2 => 5.0 is actually two major releases (4.4 and 5.0). The release versioning scheme changed starting from MongoDB 5.0 so going forward the annual major release versions are #.0 (5.0, 6.0, …).

Regards,
Stennie

2 Likes