Mongoexport -host $HOST -u $USERNAME -p $PASSWORD -db $DB -c $collection -jsonArray -o $collection. Mongoimport $ARGS -d $DB -c $collection $pathĭATABASE_COLLECTIONS=$(mongo $CONN $ARGS -quiet -eval 'db.getCollectionNames()' | sed 's/,/ /g')įor collection in $DATABASE_COLLECTIONS do If you want to use mongoexport and mongoimport to export/import each collection from database, I think this utility can be helpful for you. There are other acceptable solutions above, but this Unix pipeline is relatively short and sweet: mongo -quiet mydatabase -eval "db.getCollectionNames().join('\n')" | \ And for that I wanted the answer to the original question. However, I needed a quick and dirty solution that would likely be forwards and backwards compatible between old and new versions of MongoDB, provided there's nothing especially wacky going on. The current file is robo3t-1.1. but obviously this may be different to what you downloaded in the future: adapt the commands below accordingly. I realize that this is quite an old question and that mongodump/mongorestore is clearly the right way if you want a 100% faithful result, including indexes. Robomongo is now Robo 3T: Download the tar file from the site. Percona Server for MongoDB 5.0 Documentation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |