Import and export data into mongodb using mongobackup. This grunt task is a simple wrapper around mongodump and mongorestore. It's a great way to configure your backups and share data.
This plugin requires Grunt `~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-mongo-backup --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-mongo-backup');
In your project's Gruntfile, add a section named mongobackup
to the data object passed into grunt.initConfig()
. This is a multi-task, so feel free to add as many configurations as you want.
grunt.initConfig({
mongobackup: {
local: {
options: {
host: 'localhost',
port: '27017',
db: 'database-dev',
dump:{
out: './dump',
},
restore:{
path: './dump/database-dev',
drop: true
}
}
}
}
});
grunt mongobackup:db:dump
grunt mongobackup:db:restore
Consult mongodb docs - mongodump and mongorestore for optional params.
NOTE: NOT ALL OPTIONS ARE AVAILABLE. Change to suit your needs.