[NPM version](https://www.npmjs.com/package/mongodb-backup-dump)
npm install mongodb-backup-dumpUsing npm:
``bash`
$ npm install mongodb-backup-dump
Using bower:
`bash`
$ bower install mongodb-backup-dump
Using yarn:
`bash`
$ yarn add mongodb-backup-dump
`js
const mongodbBackup = require('mongodb-backup-dump');
/*
Backup of your local MongoDB data will be created in ./backup/${currentDate}
*/
mongodbBackup.createBackup();
const host = '192.168.1.08';
const port = 27017;
const backupDest = 'myBackup'
/* All params are optional having default values as following:
host = 127.0.0.1 i.e localhost
port = 27017
backupDest = currentDate
*/
mongodbBackup.createBackup(host, port, backupDest);
`
const mongodbBackup = require('mongodb-backup-dump');
/*
Backup of your local MongoDB data will be created in ./backup/${currentDate}
*/
mongodbBackup.restoreBackup('./myBackup');
const host = '192.168.1.08';
const port = 27017;
/* Host and port params are optional having default values as following:
host = 127.0.0.1 i.e localhost
port = 27017
*/
mongodbBackup.restoreBackup('./myBackup',host, port);
`
const mongodbBackup = require('mongodb-backup-dump');
/*
Backup of your local MongoDB data will be created in ./backup/${currentDate}
*/
mongodbBackup.scheduleBackup(' 1 *');
const cronScheduler = ' 1 *';
const host = '192.168.1.08';
const port = 27017;
const backupDest = 'myBackup';
/* All params are optional having default values as following:
cronScheduler = 1 * // will run on 1 AM every day
host = 127.0.0.1 i.e localhost
port = 27017
backupDest = //scheduling date
*/
mongodbBackup.scheduleBackup(cronScheduler,host, port, backupDest);
`
The cron format consists of:
```
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ │
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59)