Skip to content

Instantly share code, notes, and snippets.

@abdulhadad
Last active June 21, 2019 19:27
Show Gist options
  • Select an option

  • Save abdulhadad/6a0b67df4746d2c0317224825ffe4857 to your computer and use it in GitHub Desktop.

Select an option

Save abdulhadad/6a0b67df4746d2c0317224825ffe4857 to your computer and use it in GitHub Desktop.
mongodb janitor

Dump collection

"C:\Program Files\MongoDB\Server\4.0\bin\mongodump" --host 10.xxx.111.xx --port 54xxx --db users --collection authentication  --out mongodump-users

Restore collection

## db and collection must be exist
"C:\Program Files\MongoDB\Server\4.0\bin\mongorestore" --host localhost --port 27017 mongodump-users\

Empty collection

"C:\Program Files\MongoDB\Server\4.0\bin\mongo" --host localhost --port 27017 authentication  --eval "db.users.remove({})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment