I'm using the following script to backup my IIS and MySQL data directories to a SkyDrive folder than then uploads to the cloud, but SkyDrive has an issue with files beginning with a space or null character and won't upload properly.
I don't care about these particular two files as they are a language add-on for a wordpress theme, so i'd like to exclude them from the robocopy script.
How do I 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 [email protected]
set [email protected]
set EmailSubject=%~nx0: mycompany backup Results for %dd%%mm%%yyyy%
REM Optional; leave empty if the user running the task can send directly to the smtp server:
set EmailUser=
REM Because of passwords potentially containing characters with special meaning in batch,
REM the password string *has* to be enclosed in double quotes when setting the variable!
set EmailPass=""
SET _what=/COPYALL /B /MIR
:: /COPYALL :: COPY ALL file info
:: /B :: copy files in Backup mode.
:: /MIR :: MIRror a 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 to existing Output log file
:: /NDL :: No directory logging
:: /NP :: No % percentage logging
:: /XD :: exclude directories
:: /XF :: exclude file(s)
net stop w3svc
net stop WAS
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 WAS
net start w3svc
As you can see, I'm excluding files using a wildcard - *ar.*
- but what if there happens to be a file ending in "ar" with any extension (eg. hirecar.html)?
There is only two 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 the search pattern contains spaces, it must be enclosed in double quotes.