Mongodb backup and restore command

Time:2021-7-26

backups

mongodump --archive=gt_ut.archive --db gt_ut
2018-03-22T18:11:33.555+0800    writing gt_ut.gt_counting_data to archive 'gt_ut.archive'
2018-03-22T18:11:33.558+0800    done dumping gt_ut.gt_counting_data (2 documents)

Backup to file namedgt_ut.archiveFile

Attempt to repeat the backup

The first backup file is overwritten

mongodump --archive=gt_ut.archive --db gt_ut
2018-03-22T18:11:59.565+0800    writing gt_ut.gt_counting_data to archive 'gt_ut.archive'
2018-03-22T18:11:59.567+0800    done dumping gt_ut.gt_counting_data (2 documents)

Restore now

Execute after deleting a record in the collectionmongorestore, the deleted lines appear again, and errors are reported for existing linesE11000 duplicate key error

mongorestore --archive=gt_ut.archive
2018-03-22T18:13:28.986+0800    preparing collections to restore from
2018-03-22T18:13:29.019+0800    reading metadata for gt_ut.gt_counting_data from archive 'gt_ut.archive'
2018-03-22T18:13:29.019+0800    restoring gt_ut.gt_counting_data from archive 'gt_ut.archive'
2018-03-22T18:13:29.035+0800    error: E11000 duplicate key error collection: gt_ut.gt_counting_data index: _id_ dup key: { : "concurrent_test" }
2018-03-22T18:13:29.035+0800    no indexes to restore
2018-03-22T18:13:29.035+0800    finished restoring gt_ut.gt_counting_data (2 documents)
2018-03-22T18:13:29.035+0800    done

Restore after deleting DB

No exceptions recovered successfully

mongorestore --archive=gt_ut.archive
2018-03-22T18:15:19.419+0800    preparing collections to restore from
2018-03-22T18:15:19.439+0800    reading metadata for gt_ut.gt_counting_data from archive 'gt_ut.archive'
2018-03-22T18:15:19.504+0800    restoring gt_ut.gt_counting_data from archive 'gt_ut.archive'
2018-03-22T18:15:19.517+0800    no indexes to restore
2018-03-22T18:15:19.517+0800    finished restoring gt_ut.gt_counting_data (2 documents)
2018-03-22T18:15:19.517+0800    done

Recommended Today

VBS obtains the operating system and its version number

VBS obtains the operating system and its version number ? 1 2 3 4 5 6 7 8 9 10 11 12 ‘************************************** ‘*by r05e ‘* operating system and its version number ‘************************************** strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _  & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _  (“Select * from […]