Reputation: 145
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?
Upvotes: 6
Views: 1178
Reputation: 15369
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.
Upvotes: 8