Sunday, September 26, 2010

Backup Mom's Pictures Robocopy Batch file

My 77 year old mother travels to fairer weather in late fall. She has a laptop. I needed for her to back up her picture files on a regular basis. It had to be easy. It had to be free. I could not count on any other backup operation because it is hard for my mom to remember backup procedures.

My solution was to use an old and tried and true method. I have used "robocopy (Robust File Copy)" since back in the bad old days of NT 4.0. Robocopy is part of the 2003 Resource Kit, but it should be part of Vista and Windows 7. The result is the following batch file. I then just put a shortcut on her desktop and made sure she knew how to plug in the USB drive and double click on it.

The highlight of the batch file is the "if" statement section:

The first line checks for the existence of a drive "e" --- Her USB drive.

* if exist e: (

If it does exist, I call the robocopy program. Robocopy is fast once the initial copy-it only copies add/move/or changes-it will not copy existing un-modified old files. I used to mirror terabyte of data with it rather fast. It also creates a log file.

* c:\bin\robocopy "c:\documents and Settings\mom\My Documents\My Pictures" e:\momspictures\ /v /mir /r:1 /w:1 /eta /log:c:\bin\picbakup.txt

The above disected (there is a lot more optional parameters):
1. c:\bin\robocopy-This calls robocopy which I put in a folder called "bin"
2. "c:\documents and Settings\mom\My Documents\My Pictures"-This is the source. Notice " because of spaces in some folders.
3. e:\momspictures\-The target folder. I created the folder ahead of time and did an initial copy of all files.
4. /v /mir /r:1 /w:1 /eta -V is vervous, mir means mirror which will delete files that are not longer present. It is a true mirror. r:1 retry times, w:1 wait time. eta Show Estimated Time of Arrival of copied files
5. /log:c:\bin\picbakup.txt-Write a log

The rest of the "if" is an "else", which basically jumps down to tell mom that "e" is not available. (By the way, I made sure that the USB will always be "e" - more on that in different blog entry).

* ) else (
* goto noexist
* )
* goto done

The rest of batch, if successful, will open up the log file, then quit.

***** Here is the whole batch file *****

@echo off
cls
echo.
echo Mom, I am copying files from your picture folder to the thumbdrive
echo Please put the thumb drive in first in the computer and wait
echo for it to be recognized.
echo.
echo Ok, now hit any key on the keyboard to continue, for example the SPACEBAR
echo.
pause

if exist e: (
c:\bin\robocopy "c:\documents and Settings\mom\My Documents\My Pictures" e:\momspictures\ /v /mir /r:1 /w:1 /eta /log:c:\bin\picbakup.txt
) else (
goto noexist
)
goto done

:noexist
cls
echo Mom, I can't find the E: drive.
echo Please make sure you can see E: on your computer first then try again.
echo Sorry. Hit any Key on the Keyboard to quit now please!
pause
goto quit

:done
cls
echo OK done!
echo When you hit the next key, the log file will open.
pause
start c:\bin\picbakup.txt
goto quit

:quit

Delco

No comments: