Mongodb database synchronization by Dropbox

I am using a mongodb database called "mydb" in a local wep application that I am developing and want to sync db files with Dropbox, so I will be available on all my development machines.

Whenever I insert some new data into the database, the files "mydb.0" and "mydb.ns" do not seem to change. Therefore, Dropbox does not synchronize anything. Any ideas here?

I know this may seem like a terrible idea, but I'm the only database user and I never run a database on multiple machines at a time. Nor do I transfer files to anyone else. It is just to make sure that I can continue to work on another machine where I stayed.

+4
source share
1 answer

Unfortunately, that sounds like a terrible idea. What if Mongo works on two machines at the same time? Both databases are likely to be corrupted. A better way would be to write a script that used mongodump and mongorestore to dump the database into Dropbox and restore it from the dump. However, you will have to run these manually.

The reason you do not see any changes to the database files is probably due to the fact that Mongo predefines its database files, so their size never changes, but only the contents inside. Dropbox may not detect this. Mongo also does not write to disk immediately. Rather, it uses memory-mapped files that can later be reset (this should be a matter of seconds, although this should not be the reason).

+3
source

Source: https://habr.com/ru/post/1347378/


All Articles