I use a mongodb database called 'mydb' in a local wep-app I'm developing and want to sync the db files over Dropbox, so I will have it available on all my development machines.
Whenever I insert some new data in the database, the files 'mydb.0' and 'mydb.ns' don't seem to change. So Dropbox doesn't sync anything. Any ideas here?
I know this might sound like a horrible idea, but I'm the only database user and I never run the database on more than one machine at a time. Also I don't share the files with anyone else. It's just to take care that I can continue on another machine exactly where I left.
Logical Initial Sync Process When you perform a logical initial sync, MongoDB: Clones all databases except the local database. To clone, the mongod scans every collection in each source database and inserts all data into its own copies of these collections.
MongoDB stores data and indexes on disk in a compressed binary format.
Unfortunately this sounds like a horrible idea. What if Mongo is running on two machines at the same time? Most likely both databases will be corrupted. A better way would be to write a script that used mongodump and mongorestore to dump the database to Dropbox and restore it from the dump. You would have to run these manually though.
The reason you don't see any changes to the database files is probably because Mongo preallocates its database files, so their size never changes, just the contents inside. It may be that Dropbox doesn't discover this. Mongo also does not write to disk at once. Rather, it uses memory mapped files which may be flushed later (it should be a matter of seconds though so it shouldn't be the cause).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With