Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with rsync: either it shows me all files in the directories I am rsyncing (if using the flag -v) or nothing at all (when not using -v).

I would like to have rsync quiet except for the files which actually had to be uploaded to the far end. Is there a flag to activate this kind of reporting? I can not find this in the documentation

share|improve this question
up vote 3 down vote accepted

Yes, check out the -i flag. It gives a report of every operation in a cryptic format. See the man page for the exact definition of the format.

In order to get the list of files which are sent to the remote host, you could use the following:

rsync <options> -i <src> <dst> | grep '^<' | awk '{ print $2 }'
share|improve this answer
1  
This is reporting again all files, not the changed ones. – jeckyll2hide Jun 22 '12 at 7:33
    
@gonvaled No, only the files which are sent to the remote host are output (as <fcstpoguax filename, where the different flags show why they need to be updated). If it reports all files, something may be wrong with your test or your environment. – Oliver Jun 22 '12 at 7:41
    
I think you are right. I have taken a look at the manpage and it is described as you say. But my system is reporting all files. Maybe something wrong with the far-end ... – jeckyll2hide Jun 22 '12 at 7:43
    
Mmmm. getting closer: the reporting string is (for all files) <f..T....... According to the manpage, this is related to timestamps. – jeckyll2hide Jun 22 '12 at 7:48
    
Do you call rsync with --times? – Oliver Jun 22 '12 at 7:51

rsync with a single -v actually prints only transferred files. If everytime you are getting the complete list then it probably means that the default rsync src/dest comparison algorithm which is based on modification time + size is not suitable for your case. You may add the -c (--checksum) flag which makes rsync compare files by checksumming. Note that this obviously incurs some I/O overhead.

Slightly related is the fact that if you use --info=flist instead of -v then you get a more trimmed output of the files (you basically skip the header and footer of the typical -v output).

share|improve this answer

one thing that comes to my mind is using more verbose log format and awk'ing out what you want to get.

eg:

rsync -a --out-format="%b  %i %f" /etc/ /tmp/qq/ |awk '{if ($1>0) {print $3}}'

this is not very robust, it'll not handle well file-names with spaces.

share|improve this answer

here was the way I did it. I don't think there is a flag to do this but there might be now

rsync -v [other options] | grep -v 'uptodate'
share|improve this answer
1  
My rsync (version 3.0.7) does not add uptodate to the reporting, so not possible to filter that out. – jeckyll2hide Jun 22 '12 at 7:37

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.