"MongoDB" Backup

Source: Internet
Author: User
Tags file copy mongodb mongodump

Method One:

Use a file copy form to make a backup of the MongoDB data file.



[Mongo@localhost ~]$ cat mongo_back.sh #!/bin/sh
#su-mongo
Source/home/mongo/.bash_profile


#对数据库进行加锁, prevents data from being written, synchronizes data, and flushes dirty data to disk. To ensure that the files in the data directory are the most current data.


/opt/mongodb/mongodb-linux-x86_64-2.5.5/bin/mongo-start.sh <<eof

Db.fsynclock ()

Eof


#拷贝数据文件到备份目录中
#cp datafile to Backup/dir

Cp-r/opt/mongodb/db/mdsp/opt/backup/mdsp_bak


#解锁, the database is restored to a writable state
#unlock DB

/opt/mongodb/mongodb-linux-x86_64-2.5.5/bin/mongo-start.sh <<eof

Db.fsyncunlock ()

Eof

[Mongo@localhost ~]$


Method Two.

Use Mongodump to export data to a backup directory


Mongodump-o/opt/backup/-port 27018-d mdsp-u backuser-p



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.