Full Disclosure: I am a long-term Microsoft Windows user and developer and I haven’t used any sort of Cron job in about 12 years, so all this was new to me.
What is a Cron job?
It’s just something that runs chronically, i.e. an automated procedure on the server that runs every day or hour.
What is MySqlDump?
It’s a nice simple way to do a backup of a MySql Database
What is GZip Compression?
It is the Linux version of zipping a file, using whatever open source algorithm they use.
How do Cron Jobs, MySqlDump and GZip Compression come together?
In my case, I needed to backup a very large multisite WordPress database. After some further discover I discovered that it would behoove me to compress the database as well. Without compression, the backup file was 250 megs, with compression it was 25 megs.
What is the syntax for a Cron Job with MySqlDump and GZip Compression?
Just use this
mysqldump –opt -Q -u[YourUserName] -p[YourPassword] [YourDatabaseName] | gzip >/path/to/desired/backup/location/`date`.sql.gz
That will create a file named after the current date and time that is a zipped version of your database. It runs surprisingly quickly.
What is the catch?
The reason this particular little task took me some extra time to do is because I had forgotten that Unix system use the back tick character (`) and not the single quote (‘). FYI – the back tick character is the one located underneath the escape key.
|
Written By Steve French |
Leave a Reply