gzip backup a mysql database

It’s handy, fast, and convienient to you mysql on the command line.
Lately, what I’ve been using it most for is to back up and restore
databases. I don’t do it often enough to have the commands committed to
memory, but everytime I need it I go searching for it again. Rather
than trying to find my previous search results again I’ll post them here
with a summary.

To back a mysql database into a gzipped archive:

mysqldump [database] | gzip > backup.sql.gz

To restore the backup:

gunzip < backup.sql.gz | mysql [database]

Reference: web cheat sheet

RSS feed | Trackback URI

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NoDerivs 2.5 License.