I have a .cmd file that i want to use in automating copying a folder from a mapped location on a windows 2008 server to an external HDD connected to the windows server box:
@ECHO OFF
ECHO Backup process started.
set TARGET_FOLDER=Z:\"WindowsImageBackup - Copy"
ECHO TARGET_FOLDER "%TARGET_FOLDER%"
SET DESTINATION_FOLDER=H:\SERVER_BACKUP_IMAGE
ECHO DESTINATION_FOLDER "%DESTINATION_FOLDER%"
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set mydate=%%d%%c%%b%%a)
For /f "tokens=1-2 delims=: " %%a in ('time /t') do (set mytime=%%a%%b)
SET BACKUP_FOLDER=BACKUP_%mydate%_%mytime%
ECHO BACKUP_FOLDER "%BACKUP_FOLDER%"
SET FINAL_FOLDER=%DESTINATION_FOLDER%\%BACKUP_FOLDER%
MKDIR "%FINAL_FOLDER%"
ECHO DIRECTORY CREATED "%FINAL_FOLDER%"
ECHO Backup process started ...
XCOPY "%TARGET_FOLDER%" "%FINAL_FOLDER%" >> "%FINAL_FOLDER%\%BACKUP_FOLDER%.log" /Y
ECHO Backup process ended successfully.
@ECHO ON
pause
After running the script, the destination folder is created and the log file created says 0 files copied but there are files in the target folder. This is the output:
Backup process started. TARGET_FOLDER "Z:\"WindowsImageBackup - Copy"" DESTINATION_FOLDER "H:\SERVER_BACKUP_IMAGE" BACKUP_FOLDER "BACKUP_20131409Sat_0333" DIRECTORY CREATED "H:\SERVER_BACKUP_IMAGE\BACKUP_20131409Sat_0333" Backup process started ... Invalid number of parameters Backup process ended successfully.
C:\Control>pause Press any key to continue . . .
The 7th line is of interest but I do not know how to go around it. What parameters am i supposed to use?
Funny thing is that if i run this same script on my windows 7 laptop (i have the same directory structure), it runs and copies accordingly.
Thanks for your help.