mongodump -h hostname --port=port -d dbname --gzip --archive=path_to_archive_including_archive_file_name
To get the uncompressed version, exclude the --gzip flag
mongodump -h hostname --port=port -d dbname -u username -p "password" --gzip --archive=path_to_archive_including_archive_file_name
mongodump -h hostname --port=port -d dbname --collection collection_name --gzip --archive=path_to_archive_including_archive_file_name
The query parameter should be a JSON document. Ensure that the query parameter is enclosed in single quotes(e.g. ') for UNIX system and double quotes(e.g. ") fir Windows system
mongodump -h hostname --port=port -d dbname --collection collection_name -q '{query}' --gzip --archive=path_to_archive_including_archive_file_name