Backups 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.
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.