Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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...

share|improve this answer
    
Oops. My bad. I copied the line from when I was troubleshooting. I changed it now. –  Jerome Christopher Geronimo Jul 22 '13 at 10:37

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
)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.