Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@dotmind/node-mongo-dump
Advanced tools
Readme
Backup your MongoDB database on a specific frequency using mongodump.
npm i @dotmind/node-mongo-dump --save
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 🚀
Arguments | Required | type | Default Value | Commentary |
---|---|---|---|---|
dbName* | true | string | Your database name | |
frequency | false | string | '0 0 * * *' | How often you want to dump your database. |
nbSaved | false | number | 14 | The number of dumps you want to keep. If you reach the nbSaved, it will delete the oldest before saving a new one. |
host | false | string | 'localhost' | Your mongodb host. |
port | false | string | '27017' | Your mongodb port. |
outPath | false | string | './../../dumps/' | The directory where you want to save the dumps. |
withStdout | false | boolean | false | Variable to log the output of mongodump command |
withStderr | false | boolean | false | Variable to log the errors of mongodump command |
withClose | false | boolean | false | Variable to log the ouendtput of mongodump command |
Arguments | Required | type | Default Value | Commentary |
---|---|---|---|---|
dbName* | true | string | Your database name | |
nbSaved | false | number | 14 | The number of dumps you want to keep. If you reach the nbSaved, it will delete the oldest before saving a new one. |
host | false | string | 'localhost' | Your mongodb host. |
port | false | string | '27017' | Your mongodb port. |
outPath | false | string | './../../dumps/' | The directory where you want to save the dumps. |
withStdout | false | boolean | false | Variable to log the output of mongodump command |
withStderr | false | boolean | false | Variable to log the errors of mongodump command |
withClose | false | boolean | false | Variable to log the ouendtput of mongodump command |
Return the path where the file is saved.
FAQs
An npm package to generate database dump with customizable node cron
The npm package @dotmind/node-mongo-dump receives a total of 4 weekly downloads. As such, @dotmind/node-mongo-dump popularity was classified as not popular.
We found that @dotmind/node-mongo-dump demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.