https://github.com/hmarzban/mongo-backup
Node library for backup mongodb database or collects
https://github.com/hmarzban/mongo-backup
Last synced: 7 months ago
JSON representation
Node library for backup mongodb database or collects
- Host: GitHub
- URL: https://github.com/hmarzban/mongo-backup
- Owner: HMarzban
- License: apache-2.0
- Created: 2019-02-27T16:31:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-27T17:37:44.000Z (over 6 years ago)
- Last Synced: 2025-01-29T12:28:16.802Z (8 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongo-backup
Node library for backup mongodb database or coolections.### mongodump
```javascript
const { mongoexport } = require("./command");
const outputDir = `./backup/review_${new Date().getTime()}`;(async () => {
const options = {
gzip: true,
hostName: "localhost",
portName: "27017",
databaseName: "appReview",
output: outputDir,
}try {
const response = await mongodump(options);
} catch (error) {
console.log(error)
}})()
```
### mongoexport
```javascript
const { mongoexport } = require("./command");
const outputDir = `./backup/rate_${new Date().getTime()}`(async () => {
const options = {
hostName: "localhost",
portName: "27017",
databaseName: "appReview",
collectionName: "rate",
output: `${outputDir}.json`
}try {
const response = await mongoexport(options);
} catch (error) {
console.log(error)
}})()
```
### Note: (windows users)
Make sure `mongoexport` and `mongoexport` avilabe by `CMD` before using this library,
by adding mongo the `./bin` folder in `systems variablrs -> path` in Environment Variables panel.For more options and descriptions follow [this link.](./command.js)