未findBlob:使用Linux脚本将tar.gz上传到Azure存储容器时出错

错误

门户网站显示Blob not found.Blob not found. 错误

在这里输入图像说明

这是我点击downloadbutton时得到的XML错误

 <Error> <Code>ResourceNotFound</Code> <Message> The specified resource does not exist. RequestId:bea21dfd-0001-004f-26e0-220af6000000 Time:2015-11-19T15:38:55.9836819Z </Message> </Error> 

背景

我一直在尝试在Azure中备份我的IaaS v2 Ubuntu VM。 感谢我在服务器错误最近收到的一个很好的答案 ,我决定最好的路线就是定期备份我的服务器使用tar和cronjob。

所以,我search了“linux azure虚拟机上的tar备份” – 这引出了我的这篇文章 ,即: 如何在不closures虚拟机的情况下在Azure上进行Linux备份

本教程概述了执行tar命令的过程,然后使用列出的凭证将tar上传到一个azure存储容器 。 这里是有问题的脚本:

 #!/bin/bash # full system backup # Backup destination backdest=/opt/backup # Labels for backup name pc=${HOSTNAME} distro=`uname -a | awk '{print $4}'` type=full date=$(date "+%F") backupfile="$backdest/$distro-$type-$date.tar.gz" username=`whoami` #blob storage variables storageAccountName=storageaccountname storageAccountKey=mylongassstoragekey storageContainer=backupcontainername # Exclude file location prog=${0##*/} # Program name from filename excdir=`pwd` exclude_file="$excdir/$prog-exc.txt" #check backup destination is there if [ ! -d "$backdest" ]; then mkdir -p $backdest fi # Check if exclude file exists if [ ! -f $exclude_file ]; then echo "checking exclude $exclude_file" echo -n "No exclude file exists, continue? (y/n): " read continue if [ $continue == "n" ]; then exit; fi fi #don't use nohup we want to make this blocking tar --exclude-from=$exclude_file -czpvf $backupfile / #after tar is finished move to blob storage azure storage blob upload -a $storageAccountName --container $storageContainer -k $storageAccountKey $backupfile echo "all done!" 

一切似乎顺利,脚本运行备份,然后将tar.gz作为块blob上传。 但是,从上面的错误中可以看出,没有发现Blob。 存储容器被设置为“Container”(而不是“Private”)。

我不知道如何开始解决这个问题。 我该怎么办? 任何帮助都将不胜感激。 非常感谢!

Blob名称要求您转义保留的URL字符。 您的blob名称以#为保留的URL字符开头。 我怀疑这个问题会在你移除该字符时自行解决(或者逃脱)。 注意:我还没有通过独立testing证实了这一点,但这是我第一次看到一个带有#字符的blob名字…

更多信息blob命名在这里 。

解决了这个问题。 夫妇在这里过错的事情:

  1. 该脚本创build了一个文件名为$distro的文件,这个文件名是一个保留的URI字符# 。 我改变了脚本,以便它类似于$type_$date
  2. 存储blob命令失败(无声),因为脚本没有与sudo priveleges运行它们。 我所要做的就是将sudo添加到tarazure storage调用中,一切正常!