像MySQL一样的tar gzip mongo dump [英] tar gzip mongo dump like MySQL

查看:132
本文介绍了像MySQL一样的tar gzip mongo dump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,tar gzip mongo转储是否像MySQL转储一样?

Is there anyway to tar gzip mongo dumps like you can do with MySQL dumps?

例如,对于mysqldumps,您可以这样编写命令:

For example, for mysqldumps, you can write a command as such:

mysqldump -u <username> --password=<password> --all-databases | gzip > all-databases.`date +%F`.gz

对mongo转储有同样的方法吗?

Is there an equivalent way to do the same for mongo dumps?

对于mongo转储,我运行以下命令:

For mongo dumps I run this command:

mongodump --host localhost --out /backup

有没有一种方法可以将其通过gzip传递?我尝试过,但是没有用.

Is there a way to just pipe that to gzip? I tried, but that didn't work.

有什么想法吗?

推荐答案

版本3.2引入了gziparchive选项:

Version 3.2 introduced gzip and archive option:

mongodump --db <yourdb> --gzip --archive=/path/to/archive

然后您可以使用以下方法恢复:

Then you can restore with:

mongorestore --gzip --archive=/path/to/archive

这篇关于像MySQL一样的tar gzip mongo dump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆