MongoDB Backup & Restore
By: Wheelhub (http://www.wheelhub.es)
Introduction
This package has been created for the purpose of back up, restore and migration process of MongoDB databases.
I'ts based on two existing packages (mongodb-backup & mongodb-restore by hex7c0)
The main goal is to have an effective, developer friendly way to move data around by using a JSON configuration.
Configuration
The package constructor requires a JSON object with the proper params in order to work.
Config schema
Example config
projectName: 'MyProject' doBackup: true doRestore: true origin: url: 'mongodb://user:password@hostname.com:27017' databases: mongodbOptions: ssl: true authSource: 'admin' target: url: 'mongodb://localhost:27017' mongodbOptions: ssl: false useOriginDatabases: true databases: dbNameAppend: 'Copy' ;
Usage
Here's an example of how to use this package:
const libMongodbBackupRestore = ; async { let config = projectName: 'MyProject' doBackup: true doRestore: true origin: url: 'mongodb://user:password@hostname.com:27017' databases: mongodbOptions: ssl: true authSource: 'admin' target: url: 'mongodb://localhost:27017' mongodbOptions: ssl: false useOriginDatabases: true databases: dbNameAppend: 'Copy' ; try await ; catcherr console; };
If everything goes fine, the origin server database "myDatabase" will be backup and restored to target server with the name "myDatabaseCopy"