rsync - report only uploaded files

Solution 1:

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 }'

Solution 2:

rsync with a single -v actually prints only transferred files. If you are getting the complete list every time 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).


Solution 3:

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.

Tags:

Rsync