MySQL备份的最佳做法

编程入门 行业动态 更新时间:2024-10-28 13:25:19
本文介绍了MySQL备份的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在当前系统上备份MySQL数据库.我正在使用Shell脚本在cron作业中使用mysqldump命令.

I need to backup the MySQL database on my current system. I am using the mysqldump command in a cron job using a shell script.

以下是我的大致工作:

#!/bin/bash fileName=$(date +%H-%M) mysqldump -ubackup -hserver1.local -A database1 > /backup/$filename.sql

这大约需要1个小时才能完成,所以我的问题是这样:

This take about 1 hour to complete so my question is this:

我需要压缩数据,所以我想知道是否应该先将文件备份为纯sql然后压缩它,还是应该立即从mysqldump命令压缩它?

I need to compress the data so i would like to know if I should first back up the file as pure sql then compress it or should I compress it right away from the mysqldump command?

推荐答案

要减少中间磁盘空间的使用,您可以即时压缩:

To reduce intermediate disk space usage, you can compress on-the-fly:

mysqldump (options) | bzip2 -c > /backup/$filename.sql.bz2

这意味着您不必将整个未压缩的SQL数据写出到文件中,然后再读取回去即可对其进行压缩.

This means you won't have to write out the entire uncompressed SQL data to a file, and then read back over it to compress it.

更多推荐

MySQL备份的最佳做法

本文发布于:2023-11-04 11:20:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557792.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:备份   做法   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!