我需要执行从谷歌云存储桶到本地目录的gsutil rsync
,这可能会因为连接不良而中断/失败。所以我测试了如果我只是再次尝试rsync并继续我离开的地方会发生什么,它给出了一个error tring to删除第一次中断的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_.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文件也是正在构建的同步状态的一部分,它会尝试删除它两次(第一次作为清理的一部分,然后再次作为同步的一部分),这会导致OSError。我当前的修复方法是在rsync命令中添加一个忽略正则表达式:
gsutil rsync -C -d -r -x ".*gstmp$" gs://bucket_name ~/tmp/
现在,它会在rsync进程中忽略.gstmp,但在清理过程中仍会将其删除
发布于 2020-01-31 21:23:48
我试着重现你的用例:
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
三次。
https://stackoverflow.com/questions/59990134
复制相似问题