如何在Windows任务计划程序上计划Azcopy? [英] How to schedule azcopy on windows task schedueler?

查看:176
本文介绍了如何在Windows任务计划程序上计划Azcopy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标 将我的虚拟驱动器(Azure文件共享)同步到Azure blob存储容器

Goal Syncing my virtual drive (Azure file share) to a Azure blob storage container

解决方案 对于此解决方案,我正在使用azcopy.当我使用创建批处理文件运行azcopy时,everinging正常运行.

Solution For this solution i'm using azcopy. When i run azcopy with my create batch file, everyting is running correctly.

但是我也想像每天晚上一样安排这个时间. 为此,我将使用Windows Task Scheduler.

But i also want to schedule this, like every night. For this i will use windows tasks scheduler.

Windows任务计划程序会正确运行bat文件.我的bat文件还创建了一个日志文件.当我运行手动与任务计划程序时,日志文件中的输出是不同的.

Windows tasks scheduler runs the bat file correctly. My bat file also creates a log file. The output in the logfile is different when i run manual vs by the task scheduler.

批处理文件:

@echo off
IF EXIST C:\inetpub\wwwroot\tasks\azcopy_logs.txt (
    del C:\inetpub\wwwroot\tasks\azcopy_logs.txt
)
set LOGFILE=C:\inetpub\wwwroot\tasks\azcopy_logs.txt
call :LOG > %LOGFILE%
exit /B

:LOG

SET source="Y:\my-folder"
echo %source%
SET dest=^"https://TEST.blob.core.windows.net/my-container/?sv=2019-02-02^&ss=bfqt^&srt=sco^&sp=rwdlacup^&se=2120-02-26T14:56:15Z^&st=2020-02-26T06:56:10Z^&spr=https^&sig=TEST^"

echo %dest%

azcopy.exe sync %source% %dest%


exit

手动运行时的输出

"Y:\my-folder"
"https://TEST.blob.core.windows.net/my-container/?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2120-02-26T14:56:15Z&st=2020-02-26T06:56:10Z&spr=https&sig=TEST"

Job a84acee9-1796-f44b-4852-530d052db5a0 has started
Log file is located at: C:\Users\x\.azcopy\a84acee9-1796-f44b-4852-530d052db5a0.log


0 Files Scanned at Source, 0 Files Scanned at Destination
334 Files Scanned at Source, 672 Files Scanned at Destination, 2-sec Throughput (Mb/s): 0
The source and destination are already in sync.

由任务计划程序运行的输出

"Y:\my-folder"
"https://TEST.blob.core.windows.net/my-container/?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2120-02-26T14:56:15Z&st=2020-02-26T06:56:10Z&spr=https&sig=TEST"

Cannot perform sync due to error: sync must happen between source and destination of the same type, e.g. either file <-> file, or directory/container <-> directory/container

任务计划程序xml定义

 <?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2020-02-25T13:30:25.4791113</Date>
    <Author>my-user</Author>
    <URI>\azcopy\my task name</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2020-02-25T13:29:16</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>my-user-id</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\inetpub\wwwroot\tasks\azcopy.bat</Command>
      <WorkingDirectory>C:\inetpub\wwwroot\tasks\</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

推荐答案

最后,发现并解决了问题.

Finally, the problem found and solved.

Windows任务计划程序没有安装的Azure文件共享驱动器的权限.

Windows task scheduler doesn't have permissions to the mounted azure file share drive.

解决方案: 将源驱动器(SET source ="Y:\ my-folder")更改为UNC路径(SET source ="\ TEST.file.core.windows.net \ my-container \ my-folder")

Solution: Changed source drive (SET source="Y:\my-folder") to UNC path (SET source="\TEST.file.core.windows.net\my-container\my-folder")

这篇关于如何在Windows任务计划程序上计划Azcopy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆