zoukankan      html  css  js  c++  java
  • mongodb备份和恢复

    --------------------------备份--------------------------------------

    1.备份语句
    /usr/local/services/mongodb/bin/mongodump -h 172.17.70.190:28001 -u root -p 123456 --authenticationDatabase mgdb_livex --db=mgdb_livex -c ${table_name} -o /home/hxl/mongo_exportdata/${table_name}_${dump_date}

     

    --------------------------恢复--------------------------------------

    1.备份文件上传到服务器/tmp目录,然后进行解压
    [root@localhost tmp]# tar -xvf test1.tar.gz
    [root@localhost tmp]# tar -xvf test2.tar.gz

    解压后会生成目录
    [root@localhost tmp]# ls -1
    test1
    test2

    目录下是库名目录,库名下面是具体的数据文件
    [root@localhost mgdb_livex]# pwd
    /tmp/test1/mgdb_livex
    [root@localhost mgdb_livex]# ls -l
    total 17360
    -rw-r--r-- 1 test test 17768550 Sep 7 02:10 test1.bson
    -rw-r--r-- 1 test test 536 Sep 7 02:10 test1.metadata.json

    将数据恢复到另外的库:dbtest
    /usr/local/services/mongodb/bin/mongorestore --host 127.0.0.1 --port 28001 -u root -p 123456 --authenticationDatabase admin -d dbtest /tmp/t_chartroom_msg_20210907/mgdb_livex
    /usr/local/services/mongodb/bin/mongorestore --host 127.0.0.1 --port 28001 -u root -p 123456 --authenticationDatabase admin -d dbtest /tmp/t_chartroom_msg_client_20210907/mgdb_livex

  • 相关阅读:
    POJ 1201 Intervals 差分约束
    netframework2.0,asp.net2.0,vs.net 2005
    学习.net第一天
    VS.NET 2003 控件命名规范
    .Net生成共享程序集
    汉字的编码
    [转]用C#实现连接池
    SQL表自连接用法
    一道很好玩的OOP面试题,今天比较有空,所有做了一下
    C#编程规范(2008年4月新版)
  • 原文地址:https://www.cnblogs.com/hxlasky/p/15238176.html
Copyright © 2011-2022 走看看