Philip
Philip

Reputation: 2628

AZCopy: Summary along with detail from /V: parameter

I have the following that is working fine and producing a text file attached to an email with the following summary as an example:

[2019/07/04 10:40:16] Transfer summary:
-----------------
Total files transferred: 1
Transfer successfully:   1
Transfer skipped:        0
Transfer failed:         0
Elapsed time:            00.00:00:03

I'd like to incorporate the /V: parameter also, but I'm not sure how to have the above summary and the detail from the /V: parameter within the same file. Is this possible? Azcopy 8.1 is being used.

$azPath = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\"
Set-Location $azPath

$StorageAccountName = "#"
$StorageAccountKey = "#"
$ContainerName = "#"

$SourceFolder = "c:\test2"

$DestURL = "https://$StorageAccountName.blob.core.windows.net/$ContainerName"
$Result = .\AzCopy.exe /source:$SourceFolder /dest:$DestURL /BlobType:block /destkey:$StorageAccountKey /Y /S /XO

$Result | Out-File Result.txt
Send-MailMessage -From 'SQL Alerts <sqlalerts@#>' -To 'SQL Alerts <sqlalerts@#>' -Subject 'Backups (#): Copy to Azure' -Attachments .\Result.txt -SmtpServer 'smtp'

Upvotes: 1

Views: 1517

Answers (1)

Nancy Xiong
Nancy Xiong

Reputation: 28224

I'd like to incorporate the /V: parameter also, but I'm not sure how to have the above summary and the detail from the /V: parameter within the same file. Is this possible?

Actually, you do not need to generate a separate result txt file, if you specify a relative path following option /V, such as /V:test/azcopy1.log, then the verbose log is created in the current working directory within a subfolder named test. Refer to more details here.

For example $Result = .\AzCopy.exe /source:$SourceFolder /dest:$DestURL /BlobType:block /destkey:$StorageAccountKey /Y /S /XO /v:test/azcopy1.log. Azcopy will create a log file in your current path $azPath. The log file automatically includes the summary information.

enter image description here

Upvotes: 2

Related Questions