1. DB 또는 Collection 백업하기

mongodump \

  --host={호스트:포트} \

  --readPreference=secondary \

  --username={관리자계정} \

  --password={비밀번호} \

  --authenticationDatabase=admin \

  --db={DB이름} \

  --collection={Collection이름} \

  --query='{DB 쿼리 조건}' \

  --gzip \

  --out={결과가 저장될 경로명}

  --archive={결과가 저장될 파일명}


옵션> --out--archive 옵션은 중복 사용할 수 없음


참고> https://docs.mongodb.com/manual/reference/program/mongodump/


2. 복원하기

mongorestore ^

  --host={호스트:포트} ^

  --db={DB이름} ^

  --collection={Collection이름} ^

  --drop ^

  --gzip ^

  {복원될 데이터가 있는 경로명}

  --archive={복원될 데이터가 있는 파일명}


옵션> 복원할 경로명--archive 옵션은 중복 사용할 수 없음


참고> https://docs.mongodb.com/manual/reference/program/mongorestore/


Posted by jungtae17
,