我正在使用以下脚本将我的IIS和MySQL数据目录备份到SkyDrive文件夹,然后上传到云端,但SkyDrive存在以空格或空字符开头且无法正确上传的文件的问题。
我不关心这些特定的两个文件,因为它们是wordpress主题的语言插件,所以我想将它们从robocopy脚本中排除。
我该怎么做?
@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 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
正如您所看到的,我正在使用通配符排除文件 - *ar.*
- 但如果恰好有一个文件以“ar”结尾并带有任何扩展名(例如hirecar.html),该怎么办?
只有两个问题文件:
“ar.mo”
“ar.po”
答案 0 :(得分:1)
试试这个
ROBOCOPY C:\inetpub D:\inetpub-backups\Friday %_what% %_options% /XD *file_hosting /XF " ar.*" /LOG:"%RCLogFile%"
..或者这个:
ROBOCOPY C:\inetpub D:\inetpub-backups\Friday %_what% %_options% /XD *file_hosting /XF " *ar.*" /LOG:"%RCLogFile%"
如果搜索模式包含空格,则必须用双引号括起来。