0

I've placed the ff. code in rsync.bat:

for %%A in (%VAR_REMOTE_HOST%) do (
  set VAR_TARGET=%USER%@%%A:%VAR_TARGET_DIR%

  echo Rsync Source Dir: %VAR_SOURCE%
  setlocal ENABLEDELAYEDEXPANSION
  echo Rsync Target Dir: !VAR_TARGET!
  endlocal

  echo Syncing files...

  rsync -rltgDvzO --chmod=Dugo=rwX,Fugo=rw -e ssh %VAR_SOURCE% %VAR_TARGET%
)

where VAR_REMOTE_HOST is a comma-separated list of servers.

It outputs a list of files to rsync, along with permissions, sizes and timestamps. It even displays an rsync log at the end (sent bytes, received bytes, bytes/sec) However, the files are not sent to the target. It's as if it ran a dry-run. (but no -n option)

See screenshot here. (http://postimg.org/image/vc0kei1j1/)

Has anyone else encountered this?

2 Answers 2

1

It's as if it ran a dry-run. (but no -n option)

Take a look at your rsync line again:

rsync -nrltgDvzO 

I clearly see a -n option there...

1
  • Oops. My bad. I copied the line from when I was troubleshooting. I changed it now. Jul 22, 2013 at 10:37
0

I found the culprit! Changed %VAR_TARGET% to !VAR_TARGET! and moved endlocal to the end of the loop.

New code:

for %%A in (%VAR_REMOTE_HOST%) do (
  set VAR_TARGET=%USER%@%%A:%VAR_TARGET_DIR%

  echo Rsync Source Dir: %VAR_SOURCE%
  setlocal ENABLEDELAYEDEXPANSION
  echo Rsync Target Dir: !VAR_TARGET!

  echo Syncing files...

  rsync -rltgDvzO --chmod=Dugo=rwX,Fugo=rw -e ssh %VAR_SOURCE% !VAR_TARGET!
  endlocal
)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .