Nodejs script for the import of a subset of another Iamat database.
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.
Importing an atcode
node importDbSubset.js --atcodes someatcode --filter someconfigfile.json
Importing several atcodes
node importDbSubset.js --atcodes someatcode,test,yog18 --filter someconfigfile.json
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.
node importDbSubset.js --atcodes someNEWatcode --filter someconfigfile.json --clean --drop
node importDbSubset.js
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.
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