Backup transfer scripts for Linux to Windows

Hi folks!!!

This script will help you in understanding how to transfer the backup from a linux machine to windows. This is a small sample script you have to really tweak into it for a full proof system.
Step1: Create a share directory on windows machine

Step2: Create the script on your linux machine

#! /usr/local/bin

# specify the backup folder

# attach timestamp if required
# timestamp=`date +%d%m%y`
# dir=”$des”user1″$timestamp”

# Check if the backup source exist
if [ ! -d “$backup_src” ] ; then
echo “backup not possible directory does not exist”
echo “Source directory does not exist” | mail -s “Backup not possible: ”
# Mount the windows share point to transfer the backup
mount -t smbfs -o username=vyvaks,password=vyvaks // /mnt/backupStore/
if [ $? != 0 ]
echo ” Mount error ”
echo ” Mount error ” | mail -s “Backup not possible: ”
sleep 2
# copy the backup to mount point
cp -r $backup_src /mnt/bkup
if [ $? != 0 ]
echo “Copy Failed” | mail -s “Backup not possible: ”
umount /mnt/bkup
# Unmount the windows mount point
umount /mnt/bkup
echo “Backup sucessfully transfered” | mail -s “Backup done : ”

Step 3: Finally for scheduling add the script to the cron

Why runtime.exec hangs in Java ?

I had hit with the same problem runtime.exec() hangs when I tried to execute a lengthy batch script in windows. The Java docs had apparently described this which I never read. RTFM 😉

“Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.”

The solution was to empty the buffer so that the process won’t hit a deadlock. I have a small sample which could make you clearer.


public class ProcessHandler extends Thread {
    InputStream inputStream;
    String streamType;

    public ProcessHandler(InputStream inputStream, String streamType) {
        this.inputStream = inputStream;
        this.streamType = streamType;

    public void run() {
        try {
            InputStreamReader inpStrd = new InputStreamReader(inputStream);
            BufferedReader buffRd = new BufferedReader(inpStrd);
            String line = null;
            while ((line = buffRd.readLine()) != null) {
                System.out.println(streamType+ “::” + line);
        } catch (Exception e) {

    public static void main(String args[]) throws Exception {
        /* For windows setting to cmd.exe */
        String command[] = {
            “cmd.exe”, “/c”, args.toString()

        /* executing the command with environments set. */
        Process proc = Runtime.getRuntime().exec(command);
        /* handling the streams so that dead lock situation never occurs. */
        ProcessHandler inputStream = new ProcessHandler(proc.getInputStream(), “INPUT”);
        ProcessHandler errorStream = new ProcessHandler(proc.getErrorStream(), “ERROR”);
        /* start the stream threads */


Happy friday with Leonardo

Hi freakzz !!

Here comes another fully loaded friday,,
Leonardo Da Vinci .. his masterpiece “The Last Supper” made a rumble in the world. What is the fact behind his artz ? It took 4 years (1495 to 1498)for him to complete and he was trying out his newly invented technique know as tempera (egg yolk and vinegar) plus oil painting ON dry plaster so that he could retouch and use more colors.

Initially some argued he was using the FRESCO technique. Fresco is a way of painting were the plaster is made wet first and then painting on it. When the plaster dries up the paint is mixed and permanent. This technique had a color limitation and cannot be retouched coz once the plaster is dried then its like playing with gluezz 😉

Herez a copy of “The Last Supper”

For more secrets