Category Archives: Tech

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. :)

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.

Loving Ubuntu !

Installed latest Ubuntu 10.04 on my laptop. For those who don’t know, Ubuntu is a Linux Operating System just like Windows or more than that.

Check out the features of this new version here : http://www.ubuntu.com/desktop/features

In my experience, installation took approximately 20 minutes, asking only 7 very basic questions to me. It includes a few great enhancements to enrich your computer experience.

  • Wireless configuration was a breeze. It found my home wireless automatically and prompted for password. That’s all. I am online withing a few seconds. πŸ™‚ πŸ™‚
  • Software Center application provides access to 32000+ free/open source applications that are ready to be downloaded and installed with a single click. Yes, a single click is all you need. πŸ™‚
  • It contains an update manager that could update all my software including the Operating System with one click. I do not have to keep on downloading security updates, firefox, openoffice or chrome seperately. this cute little application lists all updates in one place where I can click “Update” and it does the rest.

You do not need to partition or install the software to see how it looks. You can experience the Ubuntu magic just by booting from the CD. Try it, and if you like it, join the revolution. πŸ™‚

A New kind of browser – Flock

Hi Guys,

Long time.. but this time I am going to start with new topics and pictures and other news.

So, I started using this cool browser called flock. This cool tool integrates a lot of internet services into convienient interface.

for example, I am writing this blog post using flock. It took me less than 10 seconds to start blogging.

More than everything, it does not cost you a penny. I am very impressed, why don’t you give it a try?