I'm trying to write a batch file that will backup selected folders when ran, date-stamp the backup folders, but subsequently only cc over new files that need to be backed up. This is what i wrote initially, but now when I run this it creates the date stamped backup folder first, then - seeing that nothing is there - does a complete backup again: @echo off
:: variables
set drive=C:\Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo ### Backing up My Documents..
%backupcmd% "%USERPROFILE%\Documents" "%drive%\%folder%\My Documents"
set hour=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%_%hour%_%time:~3,2%
echo ### Backing up Favorites...
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\%folder%\Favorites"
set hour=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%_%hour%_%time:~3,2%
echo ### Backing up Desktop...
%backupcmd% "%USERPROFILE%\Desktop" "%drive%\%folder%\Desktop"
set hour=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%_%hour%_%time:~3,2%
:: use below syntax to backup other directories...
:: %backupcmd% "...source directory..." "%drive%\...destination dir..."echo Backup Complete!
@pauseWhat should I change to do one initial full backup (first time ran), but subsequently only backup files that have changed in reference to the initial backup, while date stamping.
Thanks,
A
Use robocopy it allows you to copy time/date stamps along with many other options. Its a far better way to copy than just xcopy. It will utilize multi thread processing if in windows 7.
But just type robocopy /? in the cmd and it will tell you all you need to know the string i usually use is this
robocopy "%source%" "%destination%" /E /ZB /DCOPY:T /A-:RASHCNET /COPY:DT /R:2 /W:1 /MT:4 /XJ /FP /ETA /log+:C:\log.txt /TEE
Thanks for the input. I wrote a batch file using robocopy and it's working fine for me, but I have admin rights. When I tested it w/ a normal user they could not run it (they have full read/write/execute rights on both the home and destination folders, but not backup/local admin rights)
Is there a switch a I can write in or use to run this w/o admin rights? Just seeing what the options are, b/c plugging the local admin username/password into the batch script and/or changing user's accounts rights across the domain is not an option.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |