Google cloud platform 继续中断rsync后.gstmp文件上的gsutil rsync错误

Google cloud platform 继续中断rsync后.gstmp文件上的gsutil rsync错误,google-cloud-platform,google-cloud-storage,gcloud,rsync,gsutil,Google Cloud Platform,Google Cloud Storage,Gcloud,Rsync,Gsutil,我需要执行从google云存储桶到本地目录的gsutil rsync,这可能会由于连接不良而中断/失败。因此,我测试了如果我再次尝试rsync并继续我中断的地方会发生什么,它给出了一个错误字符串来删除第一次中断rsync留下的.gstmp文件 假设我有一个存储这些文件的桶: test1.txt test2.txt test3.txt 我运行这个gsutil rsync命令: user@machine:~/$ gsutil rsync -C -d -r gs://bucket_name ~/tm

我需要执行从google云存储桶到本地目录的
gsutil rsync
,这可能会由于连接不良而中断/失败。因此,我测试了如果我再次尝试rsync并继续我中断的地方会发生什么,它给出了一个错误字符串来删除第一次中断rsync留下的
.gstmp
文件

假设我有一个存储这些文件的桶:

test1.txt
test2.txt
test3.txt
我运行这个gsutil rsync命令:

user@machine:~/$ gsutil rsync -C -d -r gs://bucket_name ~/tmp/
我在复制test2.txt时中断了它。这将在目标目录中留下一个
test2.txt\uux.gstmp
。现在,当我再次执行相同的rsync时,会发生以下情况:

user@machine:~/$ gsutil rsync -C -d -r gs://bucket_name ~/tmp/
Building synchronization state...
Starting synchronization...
Copying gs://bucket_name/test3.txt...
Removing file:///home/user/tmp/test2.txt_.gstmp
OSError: No such file or directory.
因此,它会选择上次中断的位置,但也会标记
.gstmp
文件以进行删除,这很好。但当它真的试图删除它时,不知怎么的它已经消失了,我得到了
OSError
(就像它试图删除它两次一样)。现在,如果我再次运行相同的命令,一切正常,因为
.gstmp
文件不再存在

有没有人知道是什么原因造成的,以及如何避免

编辑:

这看起来是因为gsutil正在清理.gstmp文件,所以如果.gstmp文件也是正在生成的同步状态的一部分,它会尝试删除它两次(首先作为清理的一部分,然后作为同步的一部分),这会导致操作错误。我当前的解决方案是在rsync命令中添加一个ignore regex:

gsutil rsync -C -d -r -x ".*gstmp$" gs://bucket_name ~/tmp/

现在,它在rsync过程中忽略了.gstmp,但仍将其作为清理的一部分删除

我试图重现您的用例:

 gsutil rsync -C -d -r gs://syncbucket  temp/
 #Building synchronization state...
 #Starting synchronization...
 #Copying gs://syncbucket/test1.txt...
 #Copying gs://syncbucket/test2.txt...
 #Copying gs://syncbucket/test3.txt...
 #CCaught CTRL-C (signal 2) - exiting

 ls temp/
 #test1.txt  test2.txt  test3.txt_.gstmp

 gsutil rsync -C -d -r gs://syncbucket  temp/
 #Building synchronization state...
 #Starting synchronization...
 #Copying gs://syncbucket/test3.txt...
 #Removing file://temp/test3.txt_.gstmp
 #OSError: No such file or directory.

 ls temp/
 #test1.txt  test2.txt  test3.txt

我不确定OSError消息是什么意思,但命令运行成功,我可以在本地看到GCS中的所有文件。我不需要运行
gsutil rsync
三次。

您在哪个版本的云SDK上运行此功能?我正在运行gsutil版本:4.47我想它会继续尝试其他文件并成功复制它们。但在我的例子中,我也依赖退出代码来查看rsync是否成功,在这种情况下,它不会返回退出代码0。您好@Bart,我是GCP支持部门的Emil。我已将此问题提交给工程师,您可以跟踪它。现在,您必须使用您提出的解决方法。干杯