Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
mongodb-backup-exporter
Advanced tools
A utility for exporting MongoDB collections to JSON or CSV format.
You can install mongodb-backup-exporter
directly from PyPI using pip:
pip install mongodb-backup-exporter
Clone the repository:
git clone https://github.com/jorgecardona/mongodb-backup-exporter.git
cd mongodb-backup-exporter
Install required Python packages:
Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
Then, install the required packages:
pip install -r requirements.txt
Install mongoexport
from MongoDB Command Line Database Tools Download:
Windows: Download the MongoDB Database Tools from the MongoDB official site. After installation, ensure that the mongoexport
executable is in your system's PATH.
Linux: You can install the MongoDB Database Tools using the package manager for your distribution. For example, on Ubuntu, you can do:
uname -a
cat /etc/os-release
curl -O https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian12-x86_64-100.10.0.tgz && \
tar -xvzf mongodb-database-tools-debian12-x86_64-100.10.0.tgz && \
cd mongodb-database-tools-debian12-x86_64-100.10.0 && \
sudo cp -r bin/* /usr/local/bin/ && \
cd .. && \
rm -rf mongodb-database-tools-debian12-x86_64-100.10.0 && \
rm mongodb-database-tools-debian12-x86_64-100.10.0.tgz
mongoexport --version
which mongoexport
Alternatively, you can download the tools from the MongoDB official site.
To use the MongoDBBackupExporter
, you can instantiate it in your script:
from mongodb_backup_exporter import MongoDBBackupExporter
# Configuration for MongoDB connection
username = "your_username" # MongoDB username
password = "your_password" # MongoDB password
hostname = "your_cluster.mongodb.net" # MongoDB cluster address
db_name = "your_database_name" # Database name
mongoexport_path = "path/to/mongoexport" # Path to mongoexport executable
# Create an instance of MongoDBBackupExporter
exporter = MongoDBBackupExporter(
username=username, # The username for the MongoDB database
password=password, # The password for the MongoDB database
hostname=hostname, # The cluster address for the MongoDB connection
db_name=db_name, # The name of the database to be backed up
mongoexport_path=mongoexport_path, # Path to the mongoexport executable
output_format='json', # Specifies the format for the exported files; can be 'json' or 'csv'
json_list=True, # If True, each JSON object will be written on a new line in list format
pretty_json=True, # If True, the JSON output will be formatted for better readability
output_dir='output_directory_path', # Directory where output files will be saved; defaults to current working directory if None
collections_to_export=['collection1', 'collection2'], # Specify collections to export; if None, all collections will be exported
)
# Execute the export process
# This method will export the specified collections from the MongoDB database
# to the designated output directory in the specified format.
exporter.execute_export()
pymongo
library (install via pip install pymongo
)mongoexport
must be installed and accessible in your system's PATH.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A tool to export MongoDB collections to JSON or CSV files
We found that mongodb-backup-exporter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.