PureBytes Links
Trading Reference Links
|
Hi all
Just thought id share with everyone my backup batchfile. I thought some of
you might find it interesting.
Basically it collects the time and date , then makes a zip file on my local
d: drive, then copys my zipped file to another machine using each 'day of
the week' as directory name ... so i have seven directories called 'mon,tue'
etc .......so that means i have some extras incase i want to go 'back in
time before infection' and restore an older backup. Ummmm what else
oh yeah i have several machines i run it on so i also look at the machine
name to decide which files to backup. I put that function in so i only have
to maintain the one backup batch file. Another batch file xcopies it to the
different machines when i make a change. It also uses the 'winzip command
line' to zip files.
The program runs using the 'scheduler function' in XP ..... you can also use
the "at" command buts thats pretty clunky.
The file is pasted below and is editted with bodgy comments.
Cheers
Cameron
ymmv
Definition ... ' bodgy ': to make something work as unintended using clunky
software commands supplied by software vendors. ie 'i bodged it up' , '
thats a bodge job' , 'dont trust Cameron hes a bodgy programmer' :O)
################ start of batchfile here ###################################
rem echo on so we can see stuff
echo on
rem..............save Path Statement for returning it to its original
setting
set temppath=%path%
rem ......... add winzip to the path
path=c:\program files\winzip;%path%
rem this wakes up my pc2 incase it has gone to sleep ....dufus wireless lan
doh ...pc2 has my y:drive
nbtstat -A 192.168.1.43
rem Set up date and time variables
rem this uses the tricky token command..geesus this took a while
for /f "tokens=1-2 delims= " %%a in ('DATE /T') do set Day=%%a
rem change the order of the %c and % a if you want a different date format
for /f "tokens=2-4 delims=/ " %%a in ('DATE /T') do set Date=%%c-%%a-%%b_
for /f "tokens=1-2 delims=: " %%i in ('TIME /T') do set Time=%%i_%%j
for /f "tokens=4-7 delims=:." %%s in ('ECHO. ^| TIME') do (set Sec=_%%s%%t)
echo %Day%
echo %Date%
echo %Time%
echo %Sec%
rem....... if directories dont exist then make them
if not exist d:\backup\%computername% md d:\backup\%computername%
if not exist Y:\backup\%computername%\%Day% md
Y:\backup\%computername%\%Day%
rem if it my acerlaptop then goto :ACERLAPTOP
if %computername%==ACERLAPTOP goto ACERLAPTOP
rem looks like this batchfile is not running on my laptop so it must be one
of my backtesting/backup pcs
goto OTHERS
rem.........................................................................
..................
rem....... acerlaptop section
:ACERLAPTOP
set type=datatools_
del d:\backup\%computername%\%type%*.* /s/q
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
c:\datatools\*.*
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist Y: copy d:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=Documents_and_Settings_cam_favorites
del d:\backup\%computername%\%type%*.* /s/q
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"c:\Documents and Settings\Cam\Favorites\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist Y: copy d:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=Documents_and_Settings_cam_my_documents
del d:\backup\%computername%\%type%*.* /s/q
rem............. Zip files
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"c:\Documents and Settings\Cam\My Documents\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: copy D:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=Documents_and_Settings_cam_desktop
del d:\backup\%computername%\%type%*.* /s/q
rem............. Zip files
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"c:\Documents and Settings\Cam\DEsktop\*.*"
rem winzip32 -min -a -p -r -hs -ex
d:\backup\%computername%\%type%%date%%time%.zip "c:\Documents and
Settings\Cam\DEsktop\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: copy D:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=outloook_mail
del d:\backup\%computername%\%type%*.* /s/q
rem............. Zip files
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"d:\Outloook mail\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: copy D:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=mywork
del d:\backup\%computername%\%type%*.* /s/q
rem............. Zip files
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"c:\program files\omega research\mywork\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: copy D:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=omega_program
del d:\backup\%computername%\%type%*.* /s/q
rem............. Zip files
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"c:\program files\omega research\program\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: copy D:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=installed_apps
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -r -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip "d:\installed
apps\*.*"
set type=abt
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -r -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip "c:\program
files\omega research\ABT\*.*"
set type=FinalResults
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -r -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip
"d:\%computername%\FinalResults\*.*"
set type=csv
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip "d:\*.csv"
rem got to end section to tidy up
goto END
rem.........................................................................
.........................
rem................ others section
:OTHERS
set type=mywork
del d:\backup\%computername%\%type%*.* /s/q
rem............. Zip files
wzzip -a -p -r -whs -ex d:\backup\%computername%\%type%%date%%time%.zip
"c:\program files\omega research\mywork\*.*"
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: copy D:\backup\%computername%\%type%%date%%time%.zip
"Y:\backup\%computername%\%Day%\"
set type=abt
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -r -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip "c:\program
files\omega research\ABT\*.*"
set type=FinalResults
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -r -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip
"d:\%computername%\FinalResults\*.*"
set type=csv
rem............. Zip files
if exist y: del Y:\backup\%computername%\%Day%\%type%*.* /s/q
if exist y: wzzip -a -p -whs -ex
Y:\backup\%computername%\%Day%\%type%%date%%time%.zip "d:\*.csv"
goto END
rem
............................................................................
.................
rem ..... end section
:END
rem return path statement to its original state
path=%temppath%
rem unrem pause to check if it worked
rem pause
rem unrem exit to close the batch cmd window
rem exit
################end of batchfile here ###################################
---
|