0

If I get it right if to make mongodump in to directory that already contains previous dumped data it will still download full collection data even if is not different from data containing in the dir Though it could check the metadata. Is there a way to make it not download collection if it has not "changed" in terms I described?

Mongodb version 4.0.4

1

As at MongoDB 4.0, collection metadata doesn't include a last modified timestamp and there is no record of when mongodump last ran (or what collections were dumped).

You could write a custom script if you have a means of identifying relevant changes in your deployment since your last backup timestamp, but there are some potentially tricky aspects such as documents that have been removed.

One approach would be to use Change Streams to keep track of relevant collections that have changed since the last backup time, but this would require a replica set deployment. It is definitely possible to configure a single member replica set deployment if that suits your requirements.

It would be more ideal to use a supported backup method if your actual goal is incremental backups rather than per-collection mongodump.

0

If I get it right if to make mongodump in to directory that already contains previous dumped data it will still download full collection data even if is not different from data containing in the dir Though it could check the metadata. Is there a way to make it not download collection if it has not "changed" in terms I described?

As per MongoDB documentation here mongodump overwrites output files if they exist in the backup data folder. Before running the mongodump command multiple times, either ensure that you no longer need the files in the output folder (the default is the dump/ folder) or rename the folders or files.

When you run mongodump without any arguments, the command connects to the MongoDB instance on the local system (e.g. localhost) on port 27017 and creates a database backup named dump/ in the current directory.

To backup data from a mongod or mongos instance running on the same machine and on the default port of 27017, use the following command:

mongodump

You can also specify the --host and --port of the MongoDB instance that the mongodump should connect to. For example:

mongodump --host mongodb.example.net --port 27017

To specify a different output directory, you can use the --out or -o option:

mongodump --out /data/backup/

For further your ref here

  • Ok, actually the answer is that it not possible that I wanted in OP. – WHITECOLOR Dec 27 '18 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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