Socket
Socket
Sign inDemoInstall

@dotmind/node-mongo-dump

Package Overview
Dependencies
41
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
5
Maintainers
5
Install size
1.09 MB
Created
Weekly downloads
 

Readme

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

Last updated on 28 Mar 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc