Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotmind/node-mongo-dump

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotmind/node-mongo-dump

An npm package to generate database dump with customizable node cron

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by42.86%
Maintainers
5
Weekly downloads
 
Created
Source

node-mongo-dump

Menu

  • 💻 Installation
  • 🔨 Usage
  • 📖 Options
  • 📜 License

Backup your MongoDB database on a specific frequency using mongodump.

Version

💻 Installation

npm i @dotmind/node-mongo-dump --save

🔨 Usage

Declare the function in the js file that start your server

const nodeMongoDump = require('@dotmind/node-mongo-dump');

nodeMongoDump({
  dbName: 'YOUR_DB_NAME'
});

You can use the dumpDb function to dump the database once

const dumpDb = require('@dotmind/node-mongo-dump/lib/dumpDb');

dumpDb({
  dbName: 'dbName',
  host: 'localhost',
  port: '27017',
  nbSaved: 5,
  outPath: './dumps/',
  withStdout: false,
  withStderr: false,
  withClose: false,
});

And you can use await for a sync usage. The dumpDb function will return the path where the file is saved.

const file = await dumpDb({
  dbName: 'dbName',
  host: 'localhost',
  port: '27017',
  nbSaved: 5,
  outPath: './dumps/',
  withStdout: false,
  withStderr: false,
  withClose: false,
});

And then... That's it, you're ready to go 🚀

📖 Options

ArgumentsRequiredtypeDefault ValueCommentary
dbName*truestringYour database name
frequencyfalsestring'0 0 * * *'How often you want to dump your database.
nbSavedfalsenumber14The number of dumps you want to keep. If you reach the nbSaved, it will delete the oldest before saving a new one.
hostfalsestring'localhost'Your mongodb host.
portfalsestring'27017'Your mongodb port.
outPathfalsestring'./../../dumps/'The directory where you want to save the dumps.
withStdoutfalsebooleanfalseVariable to log the output of mongodump command
withStderrfalsebooleanfalseVariable to log the errors of mongodump command
withClosefalsebooleanfalseVariable to log the ouendtput of mongodump command

dumpDb

ArgumentsRequiredtypeDefault ValueCommentary
dbName*truestringYour database name
nbSavedfalsenumber14The number of dumps you want to keep. If you reach the nbSaved, it will delete the oldest before saving a new one.
hostfalsestring'localhost'Your mongodb host.
portfalsestring'27017'Your mongodb port.
outPathfalsestring'./../../dumps/'The directory where you want to save the dumps.
withStdoutfalsebooleanfalseVariable to log the output of mongodump command
withStderrfalsebooleanfalseVariable to log the errors of mongodump command
withClosefalsebooleanfalseVariable to log the ouendtput of mongodump command

Return the path where the file is saved.

📜 License

ISC

Keywords

FAQs

Package last updated on 28 Mar 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc