Srinivas
Srinivas

Reputation: 177

Is there any Mongodb Data backup utility

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 i.e __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');
            }
        }
    });

Upvotes: 2

Views: 1699

Answers (1)

Amit Yadav
Amit Yadav

Reputation: 1039

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.

Upvotes: 4

Related Questions