The rsync command accepts at most 2 arguments in command line

1.3k views Asked by At

Getting this error when attempting to run "gsutil rsync" command. Command below. I reinstalled Cloud SDK from scratch on VM instance. Applied kubectl component. Whether I put in one flag, two flags, three flags.

# 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

Even if I use no flags I get a similar error. (destination path is mounted version of gs:// - same location)

# 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

If I attempt to perform gsutil rsync by itself I get a similar error.

# 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!

Normal RSYNC (not through gsutil) spits out

# 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]
1

There are 1 answers

0
jarmod On BEST ANSWER

You need to change /var/www/html/* to /var/www/html. The reason is two-fold:

  1. gsutil rsync is expecting folders (/var/www/html/* is not a folder)
  2. the shell will expand the asterisk in /var/www/html/* so your command line may end up with dozens, or even 100s, of parameters.