我需要在当前系统上备份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备份的最佳做法
发布评论