26 October 2009 0 Comments

Windows xcopy batch script

I wrote a small script to copy files from one drive (C:) to the destination (Z:) using a nightly cron:

@echo off
:: variables
set drive=Z:\
set backupcmd=xcopy /s /c /d /e /h /i /r /y

echo ### BACKUP...
%backupcmd% "C:\[SOURCE]" "%drive%" 

:: If you want to exclude certain file types add this ... /Exclude:C:\bat\exclude.txt

:: use below syntax to backup other directories...
:: %backupcmd% "...source directory..." "%drive%\...destination dir..."

echo Backup Complete!

Leave a Reply