I'm connecting to a remote MongoDB server, importing all of the items from it into a local database, and then clearing it.
Is there a safer and more efficient way to do this?
mongoexport -h 1.2.3.4 -d foo -c bar | mongoimport -d foo -c bar
mongo 1.2.3.4/foo --eval "db.bar.remove()"
mongo 1.2.3.4/foo --eval "db.repairDatabase()" # To free up disk space
The remote database is much smaller than the one that I'm importing into, so replication doesn't seem like an option.