Backup Batch File

liunx

Guest
I'm no coder and it's taking me too long to try and create this. I want to be able to select which environment in the command window and back up 2 directories on the server or multiple servers and delete the contents of another directory upon selection. Here is what I pieced together so far, but of course it's still not working. It looks kind of funky in the copy, but the asterisks just create a box around the environment/server selection. This is driving me nuts Not being all that good at this plz help..... <img src="http://static.dreamincode.net/forums/style_emoticons/default/crazy.gif" style="vertical-align:middle" emoid=":crazy:" border="0" alt="crazy.gif" /> <br /><br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />echo off <br />setlocal <br /><br />SET RunFile=RunFile.txt <br /><br />cls <br />echo ******************************************************************************* <br />echo * Backups * <br />echo * * <br />echo * This routine backs up the CURRENT and PROPERTIES directories and deletes the contents of the RESOURCES directory for xxx application. * <br />echo * * <br />echo * Select the Environment being backed up: * <br />echo * [1]:UAT Column1 XXX * <br />echo * * <br />echo * * <br />echo * [2]:UAT Column2 XXX * <br />echo * * <br />echo * * <br />echo * [3]:PROD Column1 (XXX), Column2 (XXX), * <br />echo * Column3 (XXX), Column4 (XXX), * <br />echo * Column5 (XXX), Column6 (XXX) * <br />echo * Column7 (XXX) , Column8 (XXX) * <br />echo * * <br />echo * * <br />echo * [4]: DEMO1 (XXX) * <br />echo * * <br />echo * * <br />echo * [5]: DEMO2 (XXX) * <br />echo * * echo * * <br />echo * [Q]:to Quit without backing up any files. * <br />echo * * <br />echo ******************************************************************************* <br />:STARTLOOP <br />SET Choice= <br />SET /P Choice=- <br />IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1% <br />IF /I '%Choice%'=='1' GOTO 1 <br />IF /I '%Choice%'=='2' GOTO 2 <br />IF /I '%Choice%'=='3' GOTO 3 <br />IF /I '%Choice%'=='4' GOTO 4 <br />IF /I '%Choice%'=='5' GOTO 5 <br />IF /I '%Choice%'=='Q' GOTO QUITEXIT <br />ECHO "%Choice%" is not valid. Please try again. <br />ECHO. <br />GOTO STARTLOOP <br /><br /><br />:1 <br />SET Server=XXX <br />SET UserID=XXX <br />SET PWID=XXX <br />GOTO STARTROUTINE <br />:2 <br />SET Server=XXX <br />SET UserID=XXX <br />SET PWID=XXX <br />GOTO STARTROUTINE <br />:3 <br />SET Server=XXX <br />SET Server=XXX <br />SET Server=XXX <br />SET Server=XXX <br />SET Server=XXX <br />SET Server=XXX <br />SET Server=XXX <br />SET Server=XXX <br />SET UserID=XXX <br />SET PWID=XXX <br />GOTO STARTROUTINE <br />:4 <br />SET Server=XXX <br />SET UserID=XXX <br />SET PWID=XXX <br />GOTO STARTROUTINE <br />:5 <br />SET Server=XXX <br />SET UserID=XXX <br />SET PWID=XXX <br />GOTO STARTROUTINE <br /><br />:STARTROUTINE <br /><br /><br />%UserID%>> %RunFile% <br />%PWID%>> %RunFile% <br />echo :: variables <br />echo set folder=%date:~10,4%%date:~4,2%%date:~7,2% <br />echo set backupcmd=xcopy /s /c /d /e /h /i /r /k /y <br />echo. <br />echo ### Backing up Application's CURRENT and PROPERTIES directories ### <br />echo %backupcmd% "X:\Projects\APPLICATION\current" "%drive%\%folder%\current" <br />echo %backupcmd% "X:\Projects\APPLICATION\properties" "%drive%\%folder%\properties" <br />echo. <br />echo ### Removing contents of Application's RESOURCES directory ### <br />echo rm X:\Projects\Application\resources\*.* <br />echo Backup Complete! <br /><br /><br />GOTO ENDROUTINE <br /><br />:ENDROUTINE <br />endlocal <br />@pause<!--c2--></div><!--ec2--><br /><br />If anyone can help please Email <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><br /><br />~Admin Edit: Edited Title, Added
Code:
 tags.
</div>
 
Back
Top