Compress and Dump all your MySQL databases

I wanted to backup all the MySQL databases I had to retire the actual server and then migrate to a newer server. I had about 50gig of data under /var/lib/mysql/.

How to find the amount of data a of folder have

du -sh /var/lib/mysql/

How to compress and dump all your databases on a MySQL server

# Backup and compress your MySQL databases
mysqldump -u root -h localhost -p --all-databases | gzip -9 > backup_dbs.sql.gz
# Unzip the file when you are ready to import it
gunzip backup_dbs.sql.gz


Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>