mongodb-backup-toolkit
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

Mongodb Backup Toolkit

This Node.js library that allows you to easily backup and restore MongoDB databases using Mongoose and the filesystem module. The backup function writes all collections to individual JSON files in a specified directory, while the restore function reads the JSON files and inserts them into the specified database.

Installation

npm install mongodb-backup-toolkit

or yarn

yarn add mongodb-backup-toolkit

Usage

import MongoBackupToolkit from "mongodb-backup-toolkit";

// Backup
await MongoBackupToolkit.backup(
  "mongodb://localhost:27017/mydatabase",
  "backup"
);

// Restore
await MongoBackupToolkit.restore(
  "mongodb://localhost:27017/mydatabase",
  "backup"
);

Pro Tip:

If you're using Nodemon to run your application, make sure to ignore the backup folder created by the BackupToolkit. You can add the backup folder to the nodemon ignore list in your nodemon.json or nodemon.config.js file:

{
  "ignore": ["backup"]
}

API

Function Description
backup Backup a MongoDB database to a specified directory
restore Restore a MongoDB database from a specified directory

License

MIT

Package Sidebar

Install

npm i mongodb-backup-toolkit

Weekly Downloads

3

Version

1.0.8

License

ISC

Unpacked Size

23.8 kB

Total Files

9

Last publish

Collaborators

  • ssakib4040