Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.99k forks source link

[storage] az storage file copy start-batch --snapshot feature #15989

Open binnie268 opened 3 years ago

binnie268 commented 3 years ago

Is your feature request related to a problem? Please describe.

az storage file copy start-batch does not support snapshot restore

Describe the solution you'd like Describe the solution you'd like Wanted to check if we could add --file-snapshotand/or --snapshot support foraz storage file copy start-batch? Right now file snapshot is only supported on az storage file copy start

By adding the snapshot, we can restore all files from our file share snapshot to the same file share or a different file share.

Describe alternatives you've considered

Additional context

Thanks!

yonzhan commented 3 years ago

storage

Juliehzl commented 3 years ago

Hi @binnie268, thanks for your feedback. Currently you could use --source-uri with snapshot url to copy from snapshot as below:

az storage file copy start-batch --source-uri https://xxx.file.core.windows.net/test?sharesnapshot=2020-11-25T03%3A06%3A49.0000000Z --destination-share test1 --account-name xxxx
binnie268 commented 3 years ago

Hi @Juliehzl, I just tried the command but the behaviour was not expected:

az storage file copy start-batch --account-name test001 --account-key XXXXXXXXX --source-uri "https://test001.file.core.windows.net/testshare001?sharesnapshot=2020-11-23T04:26:03.0000000Z" --destination-share testshare001

I can see that my snapshot has files inside it, but the copy was empty. This was the output

copy files or blobs to file share
    account test001
      share testshare001
       path None
     source testshare001
source type file
    pattern None
 operations
[]
Juliehzl commented 3 years ago

@zhangyan133 could you take a look?

StaceyZhou2017 commented 3 years ago

hi, i am facing the same issue. is there any update?

Dilergore commented 2 years ago

Hi, is there a plan to make this work?

jonie001 commented 2 years ago

This is the result of my running az storage file copy start-batch --source-uri "https://jonieaccount.file.core.windows.net/jonieshare?sharesnapshot=2022-04-15T08:25:59.0000000Z" --destination-share jonieshares --account-name jonieaccount command. Maybe you can upgrade the CLI version and try again. Azure CLI version: azure-cli 2.35.0 core 2.35.0 telemetry 1.0.6

image
Dilergore commented 2 years ago

This is the result of my running az storage file copy start-batch --source-uri "https://jonieaccount.file.core.windows.net/jonieshare?sharesnapshot=2022-04-15T08:25:59.0000000Z" --destination-share jonieshares --account-name jonieaccount command. Maybe you can upgrade the CLI version and try again. Azure CLI version: azure-cli 2.35.0 core 2.35.0 telemetry 1.0.6 image

You are right this looks like it is working, but in reality it does not. While you are right, it is copying files, it is not copying them from the snapshot but directly from the share. Just tested it.

jonie001 commented 2 years ago

@evelyn-ys I think this may be a service bug. Can you tag it with service attention?

Dilergore commented 2 years ago

My workaround is to generate SAS with AZ CLI, then use AzCopy to copy from the snapshot. I can confirm that this is working.

echo "Get SAS Key and Create snapshot..."
tomorrow=$(date --date="tomorrow" +"%Y-%m-%d")
sasKey=$(az storage account generate-sas --https-only --permissions rwlc --services f -o tsv --account-name $storName --resource-types sco --expiry $tomorrow)
snapshotName=$(az storage share snapshot --name $oldShare --account-name $storName --query "snapshot" -o tsv)
echo "Got SAS Key and Created snapshot."

echo "Files will be copied from $oldShare to $newShare..."
azcopy copy "https://$storName.file.core.windows.net/$oldShare?$sasKey&sharesnapshot=$snapshotName" "https://$storName.file.core.windows.net/$newShare?$sasKey" --recursive
echo "Copied files from $oldShare to $newShare."

echo "Removing snapshot..."
az storage share-rm delete --storage-account $storName --name $oldShare --snapshot $snapshotName
echo "Removed snapshot."
ghost commented 2 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details
**Is your feature request related to a problem? Please describe.** az storage file copy start-batch does not support snapshot restore **Describe the solution you'd like** Describe the solution you'd like Wanted to check if we could add `--file-snapshot`and/or `--snapshot` support for` az storage file copy start-batch`? Right now file snapshot is only supported on az storage file copy start By adding the snapshot, we can restore all files from our file share snapshot to the _same_ file share or a _different_ file share. **Describe alternatives you've considered** **Additional context** Thanks!
Author: binnie268
Assignees: evelyn-ys
Labels: `Storage`, `Service Attention`, `feature-request`
Milestone: Backlog