MongoDB - henk52/knowledgesharing GitHub Wiki

MongoDB

Introduction

Purpose

References

administration Operations

Create admin password

Backup data

  • mongodump --host "SERVER_NAME:27017" --username "BACKUP_USER" --password "THE_PASSWORD" --authenticationDatabase admin --out MONGODB_BACKUP_DIR/$current_time/

restore data

mongorestore \
  --host localhost:27017 \
  --username admin \
  --password 'your_password' \
  --authenticationDatabase admin \
  --db target_database \
  --drop \
  --verbose \
  /path/to/dump/source_database/

mongorestore --host localhost:27017 --username admin --password 'your_password' --authenticationDatabase admin --db target_database --drop --verbose /path/to/dump/source_database/