简单的mongo备份(mongodump)和恢复(mongorestore)

来源:互联网 发布:网络号是什么 编辑:程序博客网 时间:2024/05/16 01:47

文件夹结构mongodb\bin\temp\IFDA

C:\Program Files\mongodb-win32-i386-1.6.5\bin\temp>..\mongodump.exe -h 192.168.1

.189
connected to: 192.168.1.189
all dbs
DATABASE: IFDA   to     dump/IFDA
        IFDA.Person to dump/IFDA/Person.bson
                 3 objects
        IFDA.system.indexes to dump/IFDA/system.indexes.bson
                 96 objects
    …………………………


C:\Program Files\mongodb-win32-i386-1.6.5\bin\temp>..\mongorestore.exe --help
usage: ..\mongorestore.exe [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)
  -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
  --port arg              server port. Can also use --host hostname:port
  -d [ --db ] arg         database to use
  -c [ --collection ] arg collection to use (some commands)
  -u [ --username ] arg   username
  -p [ --password ] arg   password
  --ipv6                  enable IPv6 support (disabled by default)
  --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
  --objcheck              validate object before inserting
  --filter arg            filter to apply before inserting
  --drop                  drop each collection before import
  --indexesLast           wait to add indexes (faster if data isn't inserted in
                          index order)

D:\mongodb\bin\temp>..\mongorestore.exe IFDA              (这是直接覆盖方法,必须将原来数据完全删除)

原创粉丝点击