MySQL 从远程转储到 tar.gz,无需 shell 访问
我正在尝试将 MySQL 转储到本地客户端。这就是我目前拥有的:
mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db |枪拉链-9> $FILE
但我想要的是 .tar.gz 而不是 Gunzip 存档。我在本地客户端上有 shell 访问权限,但在服务器上没有。因此,我无法执行远程 tar 并将其复制到此处。那么,有没有办法将 gzip 传输到 tar.gz。 (目前,.gz 不被识别为 tar 存档。)
谢谢。
I'm trying to get a dump from MySQL to my local client. This is what I currently have:
mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | gunzip -9 > $FILE
What I want though is .tar.gz instead of a gunzip archive. I have shell access on local client but not on the server. So, I can't do a remote tar and copy it here. So, is there a way of piping the gzip to a tar.gz. (Currently, the .gz does not get recognized as a tar archive.)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在客户端发出上述命令,则压缩是在客户端完成的。 mysqldump 连接远程服务器并下载不进行任何压缩的数据。
也许一些 UNIX 专家会用一个衬垫来完成这一任务。
If you are issuing the above command in client side, your compression is done in client side. mysqldump connects the remote server and downloads the data without any compression.
Probably some unix gurus will have a one liner to do it.
不。文件(是的,复数,因为 tar 通常用于多个文件)首先放置在 tar 存档中,然后然后被压缩。如果您尝试使用
tar
命令行工具,那么您需要将结果保存在临时文件中,然后对其进行 tar。但就我个人而言,我宁愿用线索打击另一方。
No. The files (yes, plural, since tar is usually used for more than one file) are first placed in a tar archive, and then that is compressed. If you are trying to use the
tar
command line tool then you will need to save the result in a temporary file and then tar that.Personally though, I'd rather hit the other side with a cluebat.
mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | tar -zcvf $FILE -
其中 $FILE 是您的文件名.tar.gz
mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | tar -zcvf $FILE -
Where $FILE is your filename.tar.gz
存档备份并按时间和日期重命名:
Archived backup and renamed by time and date: