Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 如何在文件列表上使用gsutil rsync_Google Cloud Platform_Google Cloud Storage_Rsync_Gsutil - Fatal编程技术网

Google cloud platform 如何在文件列表上使用gsutil rsync

Google cloud platform 如何在文件列表上使用gsutil rsync,google-cloud-platform,google-cloud-storage,rsync,gsutil,Google Cloud Platform,Google Cloud Storage,Rsync,Gsutil,给定一个配置文件,该文件在Google云存储中以新行分隔了一组文件夹(不能使用完整的目录列表(太大)),如下所示: gs://databucket/path/to/dir/441738 gs://databucket/path/to/dir/441739 gs://databucket/path/to/dir/441740 如何在bash脚本中使用gsutil递归地rsync文件,同时删除目标文件夹中不存在于bucket中的文件 我已经尝试在bash脚本中使用以下内容 cat ${1} | g

给定一个配置文件,该文件在Google云存储中以新行分隔了一组文件夹(不能使用完整的目录列表(太大)),如下所示:

gs://databucket/path/to/dir/441738
gs://databucket/path/to/dir/441739
gs://databucket/path/to/dir/441740
如何在bash脚本中使用gsutil递归地rsync文件,同时删除目标文件夹中不存在于bucket中的文件

我已经尝试在bash脚本中使用以下内容

cat ${1} | gsutil -m rsync -r -d ${2}
之后我收到一个错误代码126

其中,
${1}
引用上述配置文件,
${2}
引用配置文件列表中的每个文件夹要重新同步到的目标文件夹。 这与gsutil cp配合使用,但是rsync更有效地满足了我的需要

cat ${1} | gsutil -m cp -R -I ${2}
如何才能做到这一点?
谢谢

如您所知,rsync不支持使用类似-I标志的stdin函数

因此,您必须使用与cp不同的方法

如果您想在一个命令中同步多个文件夹,请编写一个批处理脚本,每行都有rsync命令,如下所示

gsutil -m rsync -r -d gs://databucket/path/to/dir/441738 *destination_folder1*
gsutil -m rsync -r -d gs://databucket/path/to/dir/441739 *destination_folder2*
gsutil -m rsync -r -d gs://databucket/path/to/dir/441740 *destination_folder3*
并运行您编写的脚本文件

这个方法有点麻烦,但它可以达到你想要的效果