MySQL Database : Quick & Easy Backup / Restore

MySQL is a great Open Source Software that is easy to setup and manage. It is available for both Windows and Unix/Linux Operating Systems ( and many others) . If you are using MySQL, here is a quick and easy way to backup and restore your MySQL databases.

This time, we are going to discuss about backup and restore using command line utilities. If you want a GUI to do this, you might as well read about the famous MySQL web administration tool, phpMyAdmin. For me, both are useful and I use them as per my convenience. This article assumes that you have shell access to MySQL server or at least remote access using mysql client from your computer to a MySQL DB Server.

Backing up the DB
We could use the mysqldump command like the one below :

For a full backup of all DBs :

 $ mysqldump  --all-databases > backup.sql 

Creating backup of a single DB:

 $ mysqldump  my_db_name > backup.sql 

This will create a text file with all data and structure of the DB. Remember, this is a quick and dirty way to do this, there are many options available to this command.

Creating backup of a single DB and using your password to login :

 $ mysqldump  --password=mypassword my_db_name > backup.sql 

For more examples and available options, run the command man mysqldump. You may also need to encrypt the backup.sql for security.

Restoring the DB
Restoring also is pretty easy. We could use the mysql command like the one below :

Run this command from where the backup.sql file is stored.

 $ mysql my_db_name < backup .sql 

Side Note : If you have shell access, you could add a cron job for running the backup command on every night or so. :)

Did you like this? Share it:
Posted in Open source, Tech | Tagged , , , , , , | 2 Comments

wget & shell scripting for automated downloads

GNU Logo - OpenSouceMy friend Leo came up with this interesting problem. He found a site where a lot of religious videos are hosted for free and he wanted to download them all. The problem is, that the site has a navigation system and you need to click 3 times to go to download page of each video. Considering that the site has about 400 videos to download, this seemed a huge task.

I knew that wget can be used for downloading files from web sites. Checking the download links of 2-3 videos revealed that the videos are stored in a particular folder (http://webserver/folder/ ) inside the webserver. The video links were all like : 1.avi , 2.avi, 3.avi and so on. Then it was all just a matter of minutes to write a small shell script. Here is the code :

#!/bin/bash
counter=0
while (($counter < 450 ));
do
echo Downloading Video $counter..
wget http://webserver/folder/$counter.avi
let counter++
done
 
echo "Done !"

I saved it as download.sh in my Ubuntu Linux machine and ran it using the below command.
rajesh@ubuntubox:~$ ./download.sh

The script took it’s time downloading files one after one .We could do parallel downloads, but that will cause trouble for the web site admins, we are nice people you know :) . Open Source saves the day !

Side Note: if you are using windows, you could probably use cygwin to do this in windows. This script is not perfect, but this did the job for us. One can easily use this as a base for developing it further for other tasks.

Did you like this? Share it:
Posted in Open source, Tech | Tagged , , , , , | Leave a comment

The Bangalore IndiBlogger Meet 2010


IndiBlogger - The Indian Blogger Community
You know how difficult it is for a system admin to skip the sunday afternoon nap?

I attended the meet. So you could guess how important it was for me.. The event was well organized if we could just forget the last moment change of the venue.

I met with some interesting bloggers from different parts of life. Most of these people are well active on twitter, I too signed up yesterday. But somehow I feel facebook is better and I am gonna stick to it for now.

I am not going to bore you with a commentary on what happened. There was coffee/tea/snacks, HP ePrint product launch, introduction of bloggers and some social awareness initiatives etc etc… It was so interesting to see people talking about what matters most to them and how they are trying to achieve it. There was some truly inspirational thoughts shared by some people. I wished somebody could have talked about Open Source there. May be next time..

The new place was far away for me, and…. well read on. :) There was a photo contest for the participants and I took a picture of a traffic block near the lal baug gate. No motivation or such, I just clicked and went on. But surprisingly, they chose my photo as one of the winners for a HP Printer. They might have found some meanings to it, that was not my fault anyway. :P

Overall it was fun. I will be there next time too. :)

Did you like this? Share it:
Posted in Memories | Tagged , , , , | Leave a comment

Onam 2010 Flowers

Did you like this? Share it:
Posted in Memories | Tagged , , , , | Leave a comment

Re-United after 12 years !

The Re-Union of Tuition Class 1998

The Re-Union of Tuition Class 1998

This one event made my Onam worth the trip. All of these people are my good friends and the first batch of my tuition classes. They all became successful in their lives. I can now proudly say that they are now in Indian Railways, Kerala State Electricity Board etc.. some of them made it into Politics and their own businesses. From the left, Anoop, Girish, Jayan,Binoop, Me, Anjith, Praveen, Vijeesh, Bijesh. Only Dixon and Shanoop failed to show up.

I was very glad to see that they all came to my home upon a very short notice.. ( called them just 1 day before ). We had lunch together and spent an afternoon talking about old times and how our lives progressed.

Just can’t express the happiness I had. It is one of those moments I felt that I did something worth living in this world. Thanks a lot for your care and friendship.

Did you like this? Share it:
Posted in Memories | Tagged , , , | Leave a comment