Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The process for utilizing mongodump to extract records that fall within a particular time frame is as follows:

  1. Determine the start and end dates of the time frame that you want to extract records from.

  2. Open a terminal or command prompt and navigate to the directory where you want to save the extracted records.

  3. Run the following command to dump the records within the time frame to a BSON file:

mongodump --db <database_name> --collection <collection_name> --query '{date_field: {$gte: ISODate("start_date"), $lte: ISODate("end_date")}}' --out dump_directory

Replace <database_name> with the name of the database that contains the collection you want to extract records from, <collection_name> with the name of the collection you want to extract records from, date_field with the name of the field that contains the timestamp or date value you want to filter on, start_date with the start date of the time frame, end_date with the end date of the time frame, and dump_directory with the name of the directory where you want to save the extracted records.

  1. Wait for the command to complete, which may take several minutes depending on the size of the collection and the number of records within the time frame.

  2. Once the command completes, you should see a directory named dump_directory in the current directory containing the BSON files for the extracted records.