Introduction to MongoDB Cluster full backup

Source: Internet
Author: User


Introduction to MongoDB Cluster Backup:

A full-library backup based on a MongoDB replica + shard architecture.

[email protected] scripts]# cat mongodb_backup.sh

#!/bin/bash

Path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/usr/local/mongodb/bin :/usr/local/mongodb/bin

Export PATH

Export Lang=en_us.utf8


dbip= "192.168.100.10"

Dport= "30000"

datetime=$ (Date +%y-%m-%d_%h_%m_%s)

Logfile= "/backup/mongodb/mongodbbak_10010/backmongo.log"

Dblist= "$ (echo ' show dbs ' |/usr/local/mongodb/bin/mongo--host ${dbip}--port ${dport} |egrep-v" Mongodb|connecting|bye "|awk ' {print$1} ')"


ECHO-E "=======start for database backup ' date +%f '%T '%u ' =======\n ' >> $Logfile

Backdbcmd () {

echo "$ (date) Backup $dbname"

/usr/local/mongodb/bin/mongodump--host ${dbip}--port ${dport}--db ${dbname}--out/backup/mongodb/mongodbbak_10010/ ${datetime}

Echo-e "$ (date) done.\n"

}


For dbname in $Dblist

Do

Echo-e "--------$dbname--------\ n" >> $Logfile

Backdbcmd >> $Logfile 2>&1

Done


Restore the entire library:

You need to specify the top level directory and delete the Config directory

/usr/local/mongodb/bin/mongorestore--port=30000--dir=/home/mongodb/2016-07-28_00_12_05--writeConcern= ' {w:0, wtimeout:200} '--numparallelcollections=8--numinsertionworkerspercollection=10--stoponerror-v--drop

Introduction to MongoDB Cluster full backup

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.