Best practices for MySQL backup

醉酒当歌 提交于 2019-12-09 06:07:09

问题


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.

Here is roughly what I do:

#!/bin/bash

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

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

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?


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/9072938/best-practices-for-mysql-backup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!