Backup only metadata using mongodump

Hi everyone,

I’m currently automating the mongodump process for both our staging and production dbs using a Python script. For this use case, I only need to export the metadata — such as collection names, indexes, and validation rules—and exclude the actual data (i.e., .bson files).

Is there a way to use mongodump (or any other tool/option) to achieve a schema-only dump without including document data?

Any help or guidance would be much appreciated!

How are you bootstrapping your prod/staging dbs if you don’t already have that information in your bootstrapping script(s)? You shouldn’t need mongodump if you don’t need the data, your regular mongodb scripts should already contain your schemas, indexes, etc?