{"id":18220154,"url":"https://github.com/dotmind/node-mongo-dump","last_synced_at":"2025-04-03T00:33:11.914Z","repository":{"id":42693451,"uuid":"317509320","full_name":"dotmind/node-mongo-dump","owner":"dotmind","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-28T08:19:55.000Z","size":224,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T09:33:19.936Z","etag":null,"topics":["mongodb","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotmind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-01T10:44:47.000Z","updated_at":"2022-03-28T12:10:27.000Z","dependencies_parsed_at":"2022-08-20T17:40:46.812Z","dependency_job_id":null,"html_url":"https://github.com/dotmind/node-mongo-dump","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotmind%2Fnode-mongo-dump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotmind%2Fnode-mongo-dump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotmind%2Fnode-mongo-dump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotmind%2Fnode-mongo-dump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotmind","download_url":"https://codeload.github.com/dotmind/node-mongo-dump/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246751464,"owners_count":20827912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mongodb","nodejs"],"created_at":"2024-11-03T20:05:11.619Z","updated_at":"2025-04-03T00:33:11.298Z","avatar_url":"https://github.com/dotmind.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-mongo-dump\n\n## Menu\n  * [💻 Installation](#installation)\n  * [🔨 Usage](#usage)\n  * [📖 Options](#options)\n  * [📜 License](#license)\n\nBackup your MongoDB database on a specific frequency using mongodump.\n\n[![Version](https://img.shields.io/npm/v/@dotmind/node-mongo-dump?color=brightgreen)](https://www.npmjs.com/package/@dotmind/node-mongo-dump)\n\n## 💻 Installation\n\n`npm i @dotmind/node-mongo-dump --save`\n\n## 🔨 Usage\n\nDeclare the function in the js file that start your server\n\n```javascript\nconst nodeMongoDump = require('@dotmind/node-mongo-dump');\n\nnodeMongoDump({\n  dbName: 'YOUR_DB_NAME'\n});\n```\n\nYou can use the dumpDb function to dump the database once\n\n```javascript\nconst dumpDb = require('@dotmind/node-mongo-dump/lib/dumpDb');\n\ndumpDb({\n  dbName: 'dbName',\n  host: 'localhost',\n  port: '27017',\n  nbSaved: 5,\n  outPath: './dumps/',\n  withStdout: false,\n  withStderr: false,\n  withClose: false,\n});\n```\n\nAnd you can use await for a sync usage. The dumpDb function will return the path where the file is saved.\n\n```javascript\nconst file = await dumpDb({\n  dbName: 'dbName',\n  host: 'localhost',\n  port: '27017',\n  nbSaved: 5,\n  outPath: './dumps/',\n  withStdout: false,\n  withStderr: false,\n  withClose: false,\n});\n```\nAnd then... That's it, you're ready to go 🚀\n\n## 📖 Options\n\n\n| Arguments  | Required  | type    | Default Value      | Commentary                                                                                                         |\n| ---------- | --------- | ------- | ------------------ | ------------------------------------------------------------------------------------------------------------------ |\n| dbName*    | true      | string  |                    | Your database name                                                                                                 |\n| frequency  | false     | string  | `'0 0 * * *'`      | How often you want to dump your database.                                                                          |\n| 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. |\n| host       | false     | string  | `'localhost'`      | Your mongodb host.                                                                                                 |\n| port       | false     | string  | `'27017'`          | Your mongodb port.                                                                                                 |\n| outPath    | false     | string  | `'./../../dumps/'` | The directory where you want to save the dumps.                                                                    |\n| withStdout | false     | boolean | `false`            | Variable to log the output of mongodump command                                                                    |\n| withStderr | false     | boolean | `false`            | Variable to log the errors of mongodump command                                                                    |\n| withClose  | false     | boolean | `false`            | Variable to log the ouendtput of mongodump command                                                                 |\n\n### dumpDb\n\n| Arguments  | Required  | type    | Default Value      | Commentary                                                                                                         |\n| ---------- | --------- | ------- | ------------------ | ------------------------------------------------------------------------------------------------------------------ |\n| dbName*    | true      | string  |                    | Your database name                                                                                                 |\n| 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. |\n| host       | false     | string  | `'localhost'`      | Your mongodb host.                                                                                                 |\n| port       | false     | string  | `'27017'`          | Your mongodb port.                                                                                                 |\n| outPath    | false     | string  | `'./../../dumps/'` | The directory where you want to save the dumps.                                                                    |\n| withStdout | false     | boolean | `false`            | Variable to log the output of mongodump command                                                                    |\n| withStderr | false     | boolean | `false`            | Variable to log the errors of mongodump command                                                                    |\n| withClose  | false     | boolean | `false`            | Variable to log the ouendtput of mongodump command              \n\nReturn the path where the file is saved.\n\n## 📜 License\n[ISC](https://choosealicense.com/licenses/isc/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotmind%2Fnode-mongo-dump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotmind%2Fnode-mongo-dump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotmind%2Fnode-mongo-dump/lists"}