windows - robocopy script exclude files beginning with a "space" -
i'm using following script backup iis , mysql data directories skydrive folder uploads cloud, skydrive has issue files beginning space or null character , won't upload properly.
i don't care these particular 2 files language add-on wordpress theme, i'd exclude them robocopy script.
how do this?
@echo off setlocal set day=%date:~7,2% set mm=%date:~4,2% set dd=%date:~7,2% set yyyy=%date:~10,4% set rclogfile=c:\backup-scripts\logs\%yyyy%%mm%%dd%_-_filesync-log.txt set emaillogfile=c:\backup-scripts\logs\%yyyy%%mm%%dd%_-_email-log.txt set emailserver=mail.emailserver.com set emailfrom=support@mycompany.com.au set emailto=user@mycompany.com.au set emailsubject=%~nx0: mycompany backup results %dd%%mm%%yyyy% rem optional; leave empty if user running task can send directly smtp server: set emailuser= rem because of passwords potentially containing characters special meaning in batch, rem password string *has* enclosed in double quotes when setting variable! set emailpass="" set _what=/copyall /b /mir :: /copyall :: copy file info :: /b :: copy files in backup mode. :: /mir :: mirror directory tree set _options=/r:3 /w:10 /ndl /np /tee :: /r:n :: number of retries :: /w:n :: wait time between retries :: /log :: output log file :: /log+ :: append existing output log file :: /ndl :: no directory logging :: /np :: no % percentage logging :: /xd :: exclude directories :: /xf :: exclude file(s) net stop w3svc net stop net stop mysql robocopy c:\inetpub d:\inetpub-backups\friday %_what% %_options% /xd *file_hosting /xf *ar.* /log:"%rclogfile%" robocopy c:\programdata\mysql d:\database-backups\offline\friday %_what% %_options% /log+:"%rclogfile%" if "%emailuser%"=="" ( set logonoption= ) else ( set logonoption= -u "%emailuser%" -pw %emailpass% ) "c:\backup-scripts\blat307\full\blat.exe" "%rclogfile%" -server %emailserver% -f %emailfrom% -t %emailto% -s "%emailsubject%" %logonoption% >"%emaillogfile%" 2>&1 net start mysql net start net start w3svc
as can see, i'm excluding files using wildcard - *ar.*
- if there happens file ending in "ar" extension (eg. hirecar.html)?
there 2 problem files:
" ar.mo"
" ar.po"
try this
robocopy c:\inetpub d:\inetpub-backups\friday %_what% %_options% /xd *file_hosting /xf " ar.*" /log:"%rclogfile%"
..or this:
robocopy c:\inetpub d:\inetpub-backups\friday %_what% %_options% /xd *file_hosting /xf " *ar.*" /log:"%rclogfile%"
if search pattern contains spaces, must enclosed in double quotes.
Comments
Post a Comment