How To Backup and Email Your Blog MySQL Database From Command Prompt?
By on September 18th, 2008

are the way of keeping your data safe and secure from disasters, and those include your personal data as well your blog database where you have been writing for days, months or years.

We have always opted for hosting providers that provide us access to Shell interfaces using which we can use putty to manage our website, this not only puts us in a better and more comfortable interface but also allows us to use CLI (command line interface) which we are pretty much comfortable with.

backup-database-from-cli-linux-tip

Once such useful command we are going to talk about is the use of CLI to backup and email your blog database in just a minute, without the hassle of multiple clicks and page loads. The command to backup your blog database from the command line is: mysqldump -u username -purpassword db_name > latest_backup_091808.sql.

In the above command mysqldump is command provided to dump your entire database to the console or to a file, the param switches are explained below;

  • -u is the switch for the database username
  • -p is the switch for the database password, there should be no space between p and you actual password
  • Replace the db_name with your blog database name.
  • The > symbol pipes the output to a file name latest_backup_091808.sql.

If you have written tons of posts, your output file will be of a huge size, so it would be better if you use a archiver to compress the file, use the command gzip latest_backup_091808.sql to compress the file, the output file be named latest_backup_091808.sql.

The final step would be to either download the file using FTP or email it to a email id using CLI. You could easily setup a shell script to run as a cronjob at regular intervals to backup your database with ease, and yes it takes less than a minute if your blog runs on a good server.

What do you think about this tutorial? Do share it among your friends and give us your views on it.

Tags: , , ,
Author: Keith Dsouza Google Profile for Keith Dsouza
I am the editor-in-chief and owner of Techie Buzz. I love coding and have contributed to several open source projects in the past. You can know more about me and my projects by visiting my Personal Website. I am also a social networking enthusiast and can be found active on twitter, you can follow Keith on twitter @keithdsouza. You can click on my name to visit my Google+ profile.

Keith Dsouza has written and can be contacted at keith@techie-buzz.com.

Leave a Reply

Name (required)

Website (optional)

 
    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'advanced_comment' not found or invalid function name in /home/keith/techie-buzz.com/htdocs/wp-includes/comment-template.php on line 1694
 
Copyright 2006-2012 Techie Buzz. All Rights Reserved. Our content may not be reproduced on other websites. Content Delivery by MaxCDN