Export a large database on a live site with a minimal load

Sometimes you need to export a very large database on a live site with heavy traffic. The Magento eCommerce platform is super intensive with the way it uses the database with it’s 300-400 tables. If you export the database in a normal fashion let’s say for a development MySQL dump or for a staging site.  It is quite easily temporarily bring the site down during the export.  This can render errors on the front-end and also the admin during the process.

Run the command below on your live site, go grab a coffee and rest assured while exporting a large database to the smallest size with a low foot print in high traffic. Yes the site may slow do a fraction, but there shouldn’t be any errors thrown. Replace localhost, user, database with your MySQL credentials.

nice -n 19 mysqldump -u user -h localhost -p --single-transaction --quick database | gzip -9 > database.sql.gz