当前位置:主页 > 资料 >

MongoDB text exports stored at Github
栏目分类:资料   发布日期:2017-05-28   浏览次数:

导读:本文为去找网小编(www.7zhao.net)为您推荐的MongoDB text exports stored at Github,希望对您有所帮助,谢谢! mongo-git-backup The tool exports text dump (via mongoexport) of given MongoDB database to given Git reposito

本文为去找网小编(www.7zhao.net)为您推荐的MongoDB text exports stored at Github,希望对您有所帮助,谢谢! 去找(www.7zhao.net欢迎您



mongo-git-backup

The tool exports text dump (via mongoexport) of given MongoDB database to given Git repository and restores it back. Please read MIT License agreement before use.

欢迎访问www.7zhao.net

Pros

  • Github and Bitbucket are safe places to store data and a history of data changes.
  • You don't need to pay for a storage if you're able to create private repos (on Bitbucket they're free).
  • You can make as many backups as you can and as often as you want since Git stores diffs instead of storing everything.
  • Git GUI clients (including web UI) allow to nicely show diffs between two versions (two commits) of data.

Cons

  • Likely, it isn't good for big databases.

Install

npm install -g mongo-git-backup 

去找(www.7zhao.net欢迎您

To run the tool on boot you need to install .

去找(www.7zhao.net欢迎您

npm install -g pm2 欢迎访问www.7zhao.net 

CLI

mongo-git-backup export options

  • --db - DB name you want to export (required)
  • --repo - a Git repository where you want to store backups (required)
  • --host - DB host (optional, localhost by default)
  • --port - DB port (optional, 27017 by default)
  • --branch - a branch of the Git repository (optional, master by default)
  • --gitUserName - Git user name (optional)
  • --gitUserEmail - Git user email (optional)
  • --daemonize - daemonize export via pm2
  • --interval - an interval of backups in seconds (works when daemonized, 300 by default)
  • --undaemonize - deletes pm2 process and removes given export settings from the list of mongo-git-backup instances

Example: 内容来自www.7zhao.net

mongo-git-backup export --db=test --repo=git@github.com:finom/mongo-git-backup.git --branch=test --daemonize 去找(www.7zhao.net欢迎您 

To run the tool on startup: copyright www.7zhao.net

  • Daemonize it first.
  • Check is mongo-git-backup run by typing pm2 ls in terminal.
  • Run pm2 save to save process list.
  • Run pm2 startup to resurrect the saved process list on startup.

See for more info.

欢迎访问www.7zhao.net

mongo-git-backup import options

  • --db - DB name you want to restore (required)
  • --repo - a Git repository where backup is stored (required)
  • --branch - a branch of the Git repository (optional, master by default)
  • --checkout - switches to a specified commit or git tag

Example:

copyright www.7zhao.net

mongo-git-backup import --db=test --repo=git@github.com:finom/mongo-git-backup.git --branch=test --checkout=tags/foo 

www.7zhao.net

Tip: add this command to NPM scripts to run it easier.

www.7zhao.net

API

There are two functions exported: exportToGit and importFromGit . Both functions return promise. The list of arguments is the same as for CLI. 内容来自www.7zhao.net

const { exportToGit, importFromGit } = require('mongo-git-backup');

const options = {
    db: 'test',
    repo: 'git@github.com:finom/mongo-git-backup.git',
    branch: 'test'
}

exportToGit(options).then(() => importFromGit(options)); copyright www.7zhao.net 
内容来自www.7zhao.net


本文原文地址:https://github.com/finom/mongo-git-backup

以上为MongoDB text exports stored at Github文章的全部内容,若您也有好的文章,欢迎与我们分享!

内容来自www.7zhao.net

Copyright ©2008-2017去找网版权所有   皖ICP备12002049号-2 皖公网安备 34088102000435号   关于我们|联系我们| 免责声明|友情链接|网站地图|手机版