1024programmer Java mongodb database backup operation

mongodb database backup operation

mongodb database backup

mongodump –host mongodb.example.net –port 27017

Backup path selection

mongodump –out /data/backup/

Select databases and collections to back up

mongodump –collection myCollection –db test

Create a non-local database backup

mongodump –host mongodb1.example.net –port 3017 –username user –password “pass” –out /opt/backup/mongodump- 2013-10-24

============================ ================================================== ================================================== =====================

Database recovery

mongorestore –port

mongorestore dump-2013-10-25/

mongorestore –oplogReplay

mongorestore –host mongodb1.example.net –port 3017 –username user –password 'pass' /opt/backup/mongodump-2013-10 -24

Cold backup

service mongod stop

Specify the location of the database file

cd /backup

mongodump –dbpath /var/lib/mongo/

service mongod start

Hot backup

# cd /backup

# mongodump –db mongodevdb –username mongodevdb –password YourSecretPwd

# ls -l dump/

drwxr-xr-x. 2 root root 4096 Sep 7 10:08 mongodevdb

Backup a specific Collection

# cd /backup

# mongodump –collection employee –db mongodevdb –username mongodevdb –password YourSecretPwd

# mongodump –collection employee –db mongodevdb –username mongodevdb –password YourSecretPwd –out /dbbackup

[local-host]# mongodump — host 192.168.1.2 –port 37017 –db mongodevdb –username mongodevdb –password YourSecretPwd

service mongod stop

cd /backup

mongorestore –dbpath /var/lib/ mongo dump

cd /backup

mongorestore –dbpath /var/lib/ mongo –db mongodevdb dump/mongodevdb

Drop the old Database before Restoring

# cd /backup

# mongorestore –dbpath /var/lib/mongo –db mongodevdb dump/ mongodevdb

# mongorestore –dbpath /var/lib/mongo –db mongodevdb –drop dump/mongodevdb

mongorestore –host 192.168.1.2 –port 3017 –db mongodevdb –username mongodevdb –password YourSecretPwd –drop /backup/dump

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/771087

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索