Created
August 2, 2016 08:43
-
-
Save matlads/a879fd92c48238a32373e15089427294 to your computer and use it in GitHub Desktop.
Bash script to output a set of mongo collections to files ( as csv )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| collections=('account', 'admin', 'alarm') | |
| MONGO_PORT=27117 | |
| MONGO_FIELDS='_id,attr_hidden,attr_hidden_id,attr_no_delete,attr_no_edit,name,site_id' | |
| for collection in ${collections[*]}; do | |
| # echo the command | |
| echo mongoexport --port $MONGO_PORT -d ace -c $collection -f $MONGO_FIELDS --csv -o $collection.csv | |
| # now actually execute it | |
| mongoexport --port $MONGO_PORT -d ace -c $collection -f $MONGO_FIELDS --csv -o $collection.csv | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment