How To Backup and Email Your Blog MySQL Database From Command Prompt?

by Keith Dsouza | Translate | Print
Thursday, 18th Sep 2008 | Share


Share How To Backup and Email Your Blog MySQL Database From Command Prompt? on Twitter Share How To Backup and Email Your Blog MySQL Database From Command Prompt? on Facebook Save How To Backup and Email Your Blog MySQL Database From Command Prompt? To Delicious Favorites Stumble How To Backup and Email Your Blog MySQL Database From Command Prompt? Share How To Backup and Email Your Blog MySQL Database From Command Prompt? on Digg Get Instant Updates as RSS Feeds from Techie Buzz

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.



Share

One Response so far | Share Your Opinions!

  1. Alfred
    July 13th, 2009 at 6:53 pm #

    nice article keith, though my knowledge of shell is at 1%
    nicely explained

    Reply to this comment

Leave a Comment

Note: We discourage users from using keywords in their names while posting comments, most of them get caught by spam, also it really would be more fruitful in knowing people who comment by their real name, rather than by using a name no one relates to. In future we reserve the right to delete comments from users using a name other than their own.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>