powershell - 如何使用 PowerShell 复制 Azure 存储中的 blob,无需覆盖且无需确认每个文件?

标签 powershell azure azure-blob-storage azure-powershell

我正在尝试使用 Azure PowerShell 模块创建 PowerShell 脚本,以将 Blob 服务容器备份到另一个备份存储帐户容器。

由于容器的大小(几TB),我希望备份是增量的,所以我不想覆盖目标容器中的文件(这对我们来说已经足够了,因为我们从不更新源容器中的现有文件)。

但是,我无法找到任何方法使脚本表现得像这样(不覆盖目标容器中的文件)而不被要求确认/拒绝每个潜在的覆盖。我希望取消此确认。

示例:

$sourceContext = New-AzureStorageContext -StorageAccountName $SourceStorageAccountName -StorageAccountKey $sourceStorageAccountKey
$destinationContext = New-AzureStorageContext -StorageAccountName $DestinationStorageAccountName -StorageAccountKey $destinationStorageAccountKey 

$blobs = Get-AzureStorageBlob -Context $sourceContext -Container $SourceContainerName

# Asks for confirmation for every blob that already exists in the destination container
$blobs | Start-AzureStorageBlobCopy -Context $sourceContext -DestContext $destinationContext -DestContainer $DestinationContainerName

最佳答案

请尝试使用-Force参数。

来自documentation :

-Force

Indicates that this cmdlet overwrites the destination blob without prompting you for confirmation.

所以你的命令是:

$blobs | Start-AzureStorageBlobCopy -Context $sourceContext -DestContext $destinationContext -DestContainer $DestinationContainerName -Force

关于powershell - 如何使用 PowerShell 复制 Azure 存储中的 blob,无需覆盖且无需确认每个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40125502/

相关文章:

c# - 解密 Blob 并将其复制到其他 Blob 存储帐户?

android - 使用 SAS(共享访问签名)通过 Azure 存储上传文件

c# - 如何使用 .NET v12 SDK 在 Azure Blob 存储中上传具有指定 ContentType 的 Blob?

mysql - mysql 的 Powershell 代码不工作

powershell - 在任务计划中添加第二个触发器

powershell - Azure Batch 容器配置中的 Azure 容器注册表的 AD 服务主体?

azure - 覆盖 Azure 移动服务表上的删除操作

python-3.x - Python azure 函数与应用程序洞察依赖性跟踪

powershell - heroku : The term 'heroku' is not recognized as the name of a cmdlet, 函数、脚本文件或可运行的程序

powershell - Azure devops - 更新 json 文件 - powershell 脚本