I like to optimize my backup strategy of my MongoDB. I have dedicated folders for each database:
storage:
dbPath: /mongodb
directoryPerDB: true
journal:
enabled: true
wiredTiger:
engineConfig:
directoryForIndexes: true
Gives folders like this:
$ tree -d /mongodb
/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?