rsync 命令在命令行中最多接受 2 个参数

The rsync command accepts at most 2 arguments in command line

尝试 运行 "gsutil rsync" 命令时出现此错误。下面命令。我在 VM 实例上从头开始重新安装了 Cloud SDK。应用了 kubectl 组件。我是插一旗,二旗,三旗。

# gsutil rsync -r -n /var/www/html/* gs://google-storage-bucket/alpha/$(date +%F)
CommandException: The rsync command accepts at most 2 arguments. Usage:

  gsutil rsync [-c] [-C] [-d] [-e] [-n] [-p] [-r] [-U] [-x] src_url dst_url

For additional help run:
  gsutil help rsync

即使我不使用标志,我也会收到类似的错误。 (目标路径是 gs:// 的挂载版本 - 相同位置)

# gsutil rsync  /var/www/html/* /var/www/_backup/alpha/$(date +%F)
CommandException: The rsync command accepts at most 2 arguments. Usage:

  gsutil rsync [-c] [-C] [-d] [-e] [-n] [-p] [-r] [-U] [-x] src_url dst_url

For additional help run:
  gsutil help rsync

如果我尝试单独执行 gsutil rsync,我会收到类似的错误。

# gsutil rsync
CommandException: The rsync command requires at least 2 arguments. Usage:

  gsutil rsync [-c] [-C] [-d] [-e] [-n] [-p] [-r] [-U] [-x] src_url dst_url

For additional help run:
  gsutil help rsync

WTF gsutility!

正常的 RSYNC(不是通过 gsutil)吐出

# rsync /var/www/html/* /var/www/_backup/alpha/$(date +%F)

rsync: change_dir#3 "/var/www/_backup/alpha" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(625) [Receiver=3.0.9]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]

您需要将 /var/www/html/* 更改为 /var/www/html。原因有两个:

  1. gsutil rsync 需要文件夹 (/var/www/html/* 不是文件夹)
  2. shell 将在 /var/www/html/*expand the asterisk 因此您的命令行最终可能会包含数十个甚至数百个参数。