416-621-9348 cgreaves@chrisgreaves.com Visit www.ChrisGreaves.com for this image! Chris_GEDC1894_Head (Small).JPG
Home Services Products

Encryption And Off-site Backup Storage (Home) ; Overview ; The Problem ; The Essence Of The Solution ; How Long Does It Take To Do A Backup? ; Assumptions ; Breakdown Of Tasks ; The Stand-Alone Solution ; The Networked Solution ; Let’s Get Started ; Mounting The Backup Drive ; Mounting An Encrypted Drive ; Waiting For The Backup Drive ; Processing Each Local Drive ; RoboCopy New And Later Files ; RoboCopy Parameter Files ; Append Session Details To A Log File ; Shutting Down the Computer ; Review For Local Systems ; Putting Together The Local Backup System ; SUBSTituting A Drive For A Folder ; Assembling The Batch File ; ( TITLE commands ); Running The Backup Batch File ; Examining Our Results ; Waiting For A Set Of Drives ; Issue the Backup Command To A Set Of Drives ; Modifying The Driving Batch File ; What About The Log File? ; The Upgraded Set Of Batch Files ; Encryption of backup data ; What Is Involved In Encrypting A Backup Device? ; ( Advice On Passwords ); What Is Involved In Mounting An Encrypted Device? ; User Mounted Or Automated? ; Using A DOS Batch File To Facilitate Mounting ; Using A DOS Batch File To Facilitate Dismounts ; Making The External Drives Available Across The Network ; Mounting A Shared Drive For Sharing ; Installing On A Networked Computer ; Running On The Big Beige Box ; An Improved Method Of Waiting ; Shutdown Or Restart? ; At Long Last! A Working Version! ; The Backup.BAT file ; The Mount.BAT file ; The ProcessDrive.BAT file ; The Shutdown.BAT File ; The Encryption Process


Loading

Toronto and Mississauga, Friday, December 03, 2010 8:26 AM

Copyright © 1996-2010 Chris Greaves. All Rights Reserved.

Assembling The Batch File

Here we go: (But see also a later set of batch files that cope with Multiple Target Backupdrives )

Backup.BAT

This is the main batch file. It should run merely by double-clicking on the name, or on a shortcut link to the file.

TITLE %0 effect a backup of a local system
::
:: Set the fixed parameters
::
Set Home=C:\SAFE\
Set Backup=F:\
Set LogFile=C:\Safe\LogFile.LOG
Set WaitTime=10
::
:: Wait until the backup drive is mounted
::
call %Home%WaitBack %Backup% %WaitTime%
::
:: Process each valid drive
::
call %Home%AllDrive %Backup%%Computername%
::
:: Make an entry in our log
::
call %Home%LogBack %LogFile%
::
:: Copy the log to the backup drive
::
Copy %LogFile% %Backup%
::
:: Shutdown the Computer system
::
call %Home%ShutDown.BAT
::
REM END

Not so bad, is it?

You should be able to recognize most of the component parts. But especially, please read TITLE commands .

I have elected to set the variable portions as four environment variables.

I can adjust the Wait Time as I grow more confident in my testing.

The Enviroment variable Home is the path to the folder that contains all the tools we have built so far.

I thought to Copy the log file to the backup drive, so we have a current record of what has been done to date.

Here for review are the current versions of the compomnent batch files:

WaitBack.BAT

Title %0 - wait for a backup drive to appear
REM parameter 1 should be the anticipated Drive and path e.g. "X:\"
REM parameter 2 should be the wait time in seconds e.g. "120"
:Loop
if exist %1 goto Finish
@echo %0 Waiting for backup drive %1 to be mounted
wait %2
GoTo Loop
:Finish
REM END

AllDrive.BAT

Note that I have made a local modifiaction, reducing the drives to be backed up to a single “T” during testing.

In practice the list would read “G P C D”.

TITLE %0 - Process all available drives
REM parameter 1 should be the Backup drive root folder e.g. "X:\LAP\"
:: For %%a in (G P C D) do ProcessDrive %%a %1
For %%a in (T) do ProcessDrive %%a %1
REM END

ProcessDrive.BAT

TITLE %0 - EFFECT THE BACKUP PROCESS FOR A SINGLE DRIVE
REM parameter 1 should be the anticipated Drive letter e.g. "C"
REM parameter 2 should be the Backup drive root folder e.g. "X:\LAP\"
if exist %1:\ RoboCopy %1:\ %2 /s /r:0 /w:1
REM END

LogBack.BAT

TITLE %0 - Log the session details to a specified file.
REM parameter 1 should be the name of the log file e.g. "C:\Safe\LogFile.log"
@echo %ComputerName% %Date% %Time% >> %1
REM END

ShutDown.BAT

Title %0 - Shut down the computer system
ShutDown.exe -s -f -t 00
REM END

Running The Backup Batch File


Loading

Toronto and Mississauga, Friday, December 03, 2010 8:26 AM

Copyright © 1996-2010 Chris Greaves. All Rights Reserved.