[Mongodb] mongodump, mongorestore 로 collection dump 하기

Woong·2023년 4월 10일
0

DB

목록 보기
16/16

mongodump 로 dump 하기

  • collection 명으로 디렉토리 생성되고, metadata json 파일 및 데이터 bson 파일 생성
mongodump --host=localhost:27017 --username=my_user --password=my_pwd --db=my_db --collection=my_collection --out=./

mongorestore 로 복구하기

  • db, collection 명은 --nsInclude 옵션으로 처리
    • ※ dump할 때와 restore할 때 db 명이 다를 경우, 디렉토리 rename 처리 후 진행
mongorestore --host=localhost:27017 --authenticationDatabase=my_db --username=my_user --password=my_pwd  --nsInclude=my_db.my_collection --dir=./

0개의 댓글