import-nodeserver-database
v1.0.0
Published
Imports a subset of the nodeserver database base on the specified criteria
Downloads
6
Readme
Iamat-Db-Subset
Nodejs script for the import of a subset of another Iamat database.
Requirements
This script is designed to work with the same requirements of the nodeserver implementation.
Beside the script must have access to a local mongodump
and mongorestore
executable files. Those files may ship altoether with the scripts depending on the platform.
How it works:
Importing an atcode
node importDbSubset.js --atcodes someatcode --filter someconfigfile.json
Importing several atcodes
node importDbSubset.js --atcodes someatcode,test,yog18 --filter someconfigfile.json
Use Cases:
To add an atcode to an existing database use somthing like
node importDbSubset.js --atcodes someNEWatcode --filter someconfigfile.json --clean
In this case the clean parameter is necesary to allow to dump the collections. It cannot override the files already in the filesystem.
Other option would be to use another dump directory.
To replace the existing database with some other atcode use somthing like
node importDbSubset.js --atcodes someNEWatcode --filter someconfigfile.json --clean --drop
To restore the database to the last import state use something like
node importDbSubset.js
Configuration
There is a base configuration in the baseConfig.json file with some posible configurations for the script.
- "host": Host for the origin mongo database
- "lhost": Host for the destination mongo database
- "port": port for the origin mongo database
- "lport": port fot the destination mongo database
- "user": user for the origin mongo database
- "luser": user for the destination mongo database
- "password": password for the origin mongo database
- "lpassword": password for the the destination mongo database
- "db": database for the origin
- "ldb": database for the destination
- "maxDays": Default days to count back for filter the records of very populated collections. It is used to calculate the minDate for the records in the collection. For example: if its set to 30, the collections that are marked to be filtered by date will import the records created(not updated) in the last 30 days.
- "atcodes": ARRAY =>the atcodes to checkout.
- "dumpDir": the directory where the dump will be stored.
- "collectionFilter": The collections to import.
- "collectionWithDateFilter": collections with filter by id creation date. see maxDays.
- "collections": Object of filters by collection to be applied while dumping.
See the file baseConfig.json for examples and default values.
Override of values in the command line
Those configurations may be overrided in the command line by args parameters.
Beside there are two possible args that can be specified to provide more control.
- atcodes: separated by commas: ex: test,yog18,mitelefe, Will override the atcodes configured in the config files.
- clean: Will erase the temp folder with the dumps and import everything again.
- dumpOnly: Will only dump the collections into the dump folder.
- drop: Will only drop the collections that are going to be restored again. ex.
node importDbSubset.js --host localhost --port 27010 -u user -p password --filter myconf.json --atcodes superatcode,test,yog18 --clean --drop