Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb database backup operation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report