티스토리 뷰
나는 아직도 단일구조로 mongoDB 를 사용하고 있는지라. 간단하게 백업 및 복원하는 방법만 알아본다.
mongodump 명령어
Export MongoDB data to BSON files.
options:
--help produce help message
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--version print the program's version and exit
-h [ --host ] arg mongo host to connect to ( <set name>/s1,s2 for
sets)
--port arg server port. Can also use --host hostname:port
--ipv6 enable IPv6 support (disabled by default)
-u [ --username ] arg username
-p [ --password ] arg password
--dbpath arg directly access mongod database files in the given
path, instead of connecting to a mongod server -
needs to lock the data directory, so cannot be used
if a mongod is currently accessing the same path
--directoryperdb if dbpath specified, each db is in a separate
directory
--journal enable journaling
-d [ --db ] arg database to use
-c [ --collection ] arg collection to use (some commands)
-o [ --out ] arg (=dump) output directory or "-" for stdout
-q [ --query ] arg json query
--oplog Use oplog for point-in-time snapshotting
--repair try to recover a crashed database
--forceTableScan force a table scan (do not use $snapshot)
db 중에 test 만 백업한다.
$>mongodump -h 127.0.0.1 -d test
connected to: 127.0.0.1
DATABASE: test to dump/test
test.users to dump/test/users.bson
1 objects
test.system.indexes to dump/test/system.indexes.bson
3 objects
test.tweets to dump/test/tweets.bson
123900/163453 75%
163453 objects
$>
mongorestore 명령어
$>mongorestore -help
usage: mongorestore [options] [directory or filename to restore from]
options:
--help produce help message
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--version print the program's version and exit
-h [ --host ] arg mongo host to connect to ( <set name>/s1,s2 for sets)
--port arg server port. Can also use --host hostname:port
--ipv6 enable IPv6 support (disabled by default)
-u [ --username ] arg username
-p [ --password ] arg password
--dbpath arg directly access mongod database files in the given
path, instead of connecting to a mongod server -
needs to lock the data directory, so cannot be used
if a mongod is currently accessing the same path
--directoryperdb if dbpath specified, each db is in a separate
directory
--journal enable journaling
-d [ --db ] arg database to use
-c [ --collection ] arg collection to use (some commands)
--objcheck validate object before inserting
--filter arg filter to apply before inserting
--drop drop each collection before import
--oplogReplay replay oplog for point-in-time restore
--keepIndexVersion don't upgrade indexes to newest version
해당 백업 파일로 복원한다.
$>mongorestore -h 127.0.0.1 ..\dump\dump_20120727
connected to: 127.0.0.1
Fri Jul 27 14:34:30 ../../../dump/dump_20120727/test/tweets.bson
Fri Jul 27 14:34:30 going into namespace [test.tweets]
83922339/271950904 30%
179830782/271950904 66%
163453 objects found
Fri Jul 27 14:34:38 ../../../dump/dump_20120727/test/users.bson
Fri Jul 27 14:34:38 going into namespace [test.users]
1 objects found
Fri Jul 27 14:34:38 ../../../dump/dump_20120727/test/system.indexes.bson
Fri Jul 27 14:34:38 going into namespace [test.system.indexes]
Fri Jul 27 14:34:38 { key: { _id: 1 }, ns: "test.users", name: "_id_" }
Fri Jul 27 14:34:38 { key: { _id: 1 }, ns: "test.tweets", name: "_id_" }
Fri Jul 27 14:34:38 { key: { tweet_id: 1.0 }, ns: "test.tweets", name: "tweet_id
_1" }
3 objects found
$>
- Total
- Today
- Yesterday
- R
- ktm모바일
- heroku
- 맥북
- 이클립스
- ipTIME
- MongoDB
- vagrant
- 셀프개통
- Google Chart Tools
- 아이맥
- eclipse
- 도넛차트
- MyBatis
- SVN
- 마인크래프트
- docker
- ggplot2
- 알뜰요금제
- ubuntu
- 자급제폰
- MySQL
- javascript
- Spring
- ggplot
- 막대그래프
- python
- Oracle
- github
- java
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |