0
What would be the most efficient way to automatically back up a MySQL Database, gzip it, and e-mail it to a specific account?
I am a bit paranoid about losing my forum's database and I'm usually busy during the week and often forget to do a weekly backup (instead, doing bi-weekly, or monthly, which isn't too bad, but less frequent than I'd like). Having it set up with a cronjob and an e-mail (or FTP/SFTP as I've just realized one of the databases would be too large to attach in an e-mail) would be a lot easier, as well as less prone to me forgetting.
How I'm looking at it now would be:
mysqldump dbname > YYYY-MM-DD_dbname.sql gzip YYYY-MM-DD_dbname.sql Either send YYYY-MM-DD_dbname.sql.gz as an attachment to an e-mail address or {S,}FTP it to another server and send an e-mail letting me know that the backup and transfer was successful.
Is there a better way to accomplish this? Any examples of how you'd accomplish it?
I wouldn't mark the checksum part as optional. The day the db crashes and you're all happy because you have a recent backup, only to find out it was corrupted is not something I would like to experience.
In addition, I'd probably use xz instead of gzip, only because the resulting file is smaller in size. – tamtakos – 2010-07-14T17:49:06.540
@tamtakos: if you skip the checksum step, as long as nothing goes wrong with the other steps, the database dump will be transferred. That makes it optional. (As opposed to, say, the
scp
step which cannot be omitted) What I think you mean to say is that the checksum should be highly recommended, and with that I agree. – David Z – 2010-07-14T21:17:17.113