I am working on mean.JS application, need to provide data backup and restore functionality for user I've come across mongodb-backup but I've issue in using this, backup file is storing in a folder where code is executed ie __dirname
is there any alternative option for storing back-up file in any other location ?
var backup = require('mongodb-backup');
backup({
uri: 'uri',
root: __dirname,
// write files into this dir
callback: function(err) {
if (err) {
console.error(err);
} else {
console.log('finish');
}
}
});
What happens when you provide "root" as some other directive instead of __dirname ?
More than that why you want to back up and restore functionality from node code itself. There are plenty of tools from mongo to achieve this -
https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/
cloud based - https://docs.mongodb.com/v3.2/core/backups/
If you want periodic backups and restore then you can create crons and scripts to achieve that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.