I like to optimize my backup strategy of my MongoDB. I have dedicated folders for each database:

  dbPath: /mongodb
  directoryPerDB: true
    enabled: true
      directoryForIndexes: true

Gives folders like this:

$ tree -d /mongodb
├── admin
│   ├── collection
│   └── index
├── config
│   ├── collection
│   └── index
├── finaldata
│   ├── collection
│   └── index
├── diagnostic.data
├── temporarydata
│   ├── collection
│   └── index
├── journal
├── local
│   ├── collection
│   └── index
└── _tmp

Folder/database temporarydata contains only temporary data, as the name implies. I like to exclude folder /mongodb/temporarydata from my backup. What happens if this folder is missing from restore, i.e. what happens if this folder is deleted.

Of course, after restore I have to create a fresh and empty temporarydata database with all collections and indexes.

The Mongo Deployment is a Sharded Cluster. Database temporarydata is sharded but all collections in this database are not sharded (I like to distribute the data by using a different Primary Shard, that's the reason why this database has sharding enabled)

Note, I don't like to delete single *.wt files as mentioned in https://serverfault.com/q/911606/463025, the entire database folder would be deleted.

Does it work?

1 Answer 1


I deployed a sharded Cluster on my PC and run a test.

  • Stopping all mongod and mongos services
  • Delete all dbPath at PRIMARY hosts
  • Delete all dbPath at ARBITER hosts
  • Delete folder temporarydata at SECONDARY hosts

Then I would have the situation like I have after a restore from filesystem restore.

  • Start SECONDARY host in standalone maintenance mode
  • Drop temporary database: db.getSiblingDB("temporarydata").dropDatabase()
  • Shutdown the MongoDB
  • Repeat above with all shards
  • Start all mongod and mongos services in your cluster

The cluster started successfully without any error - at least I did not see any. So in principle it seems to work.

However, for testing I deleted also folder+database finaldata. This database is sharded and has sharded collections. After deleting the finaldata folder I was not able anymore to start the SECONDARY mongod service - not even in "standalone maintenance mode". Option --repair does not help either.

Unless I will get a qualified answer on my question I will not go for this backup strategy, it is to risky.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.