Not recommended, something may go wrong and you will need to repair. You can use the mongorestore tool that comes with mongo to restore or migrate Chinese blog Official documentation
If you want to copy the entire file, it is possible. For the WT engine, it must also be the entire folder, because WT has its own metadata. Just copying a few collections was useless in the past. MMAPv1 has no metadata, so in theory it is enough to copy all the files corresponding to a library. However, this is not supported and its correctness is not guaranteed. If you want to copy the entire folder, you must stop access to the entire database. The easiest way is to stop the instance. Of course it is not very practical in actual use, but you can stop dropping a secondary and then perform this operation. If you want to be faster, you can also use disk snapshots without stopping the instance, but the journal must be opened and the journal and data must be on the same disk. Copying folders works for both WT and MMAPv1.
It may not work, and I don’t recommend you do it. Sometimes there will be some unexpected problems. It is recommended to import through tools or commands
Not recommended, something may go wrong and you will need to repair. You can use the mongorestore tool that comes with mongo to restore or migrate
Chinese blog
Official documentation
If you want to copy the entire file, it is possible. For the WT engine, it must also be the entire folder, because WT has its own metadata. Just copying a few collections was useless in the past. MMAPv1 has no metadata, so in theory it is enough to copy all the files corresponding to a library. However, this is not supported and its correctness is not guaranteed.
If you want to copy the entire folder, you must stop access to the entire database. The easiest way is to stop the instance. Of course it is not very practical in actual use, but you can stop dropping a
secondary
and then perform this operation. If you want to be faster, you can also use disk snapshots without stopping the instance, but the journal must be opened and the journal and data must be on the same disk.Copying folders works for both WT and MMAPv1.
It may not work, and I don’t recommend you do it. Sometimes there will be some unexpected problems. It is recommended to import through tools or commands
Found some answers, hope they help you:
Migrate mongodb database from localhost to remote servers