How to add timestamp and file list to rsync log?

I want to add both timestamp and file list to the log. Currently, I can only get one. The following command to can track the updated file list but it does not add timestamp.

rsync -avz --progress --delete /web/path/public_html/ $newhost:/web/path/public_html >> /var/log/rsync.log

sent 2345743 bytes  received 43205 bytes  530877.33 bytes/sec
total size is 14828110173  speedup is 6206.96
sending incremental file list
error_log  5740980 100%   36.98MB/s    0:00:00 (xfer#1, to-check=1405/1524)

sent 2344322 bytes  received 51694 bytes  684576.00 bytes/sec
total size is 14828115593  speedup is 6188.65

The following command can add timestamp to the log, but it doesn't tell which files were updated.

rsync -avz --progress --delete /web/path/public_html/ $newhost:/web/path/public_html --log-file=/var/log/rsync1.log --log-file-format="%t\n"

2012/01/03 17:30:05 [10505] Total transferred file size: 6170062 bytes
2012/01/03 17:30:05 [10505] Literal data: 5470 bytes
2012/01/03 17:30:05 [10505] Matched data: 6164592 bytes
2012/01/03 17:30:05 [10505] File list size: 2333282
2012/01/03 17:30:05 [10505] File list generation time: 0.002 seconds
2012/01/03 17:30:05 [10505] File list transfer time: 0.000 seconds
2012/01/03 17:30:05 [10505] Total bytes sent: 2345435
2012/01/03 17:30:05 [10505] Total bytes received: 28628
2012/01/03 17:30:05 [10505] sent 2345435 bytes  received 28628 bytes  527569.56 bytes/sec
2012/01/03 17:30:05 [10505] total size is 14828121798  speedup is 6245.88

From rsyncd.conf(5):
"The default log format is "%o %h [%a] %m (%u) %f %l", and a "%t [%p] " is always prefixed when using the "log file" parameter."

2012/01/04 03:19:12 [1461] building file list
2012/01/04 03:19:12 [1461] .d..t...... ./
2012/01/04 03:19:14 [1461] >f+++++++++ file1.pdf
2012/01/04 03:19:14 [1461] >f+++++++++ file2.pdf
2012/01/04 03:19:14 [1461] >f+++++++++ file3.pdf
2012/01/04 03:19:14 [1461] sent 40892313 bytes  received 72 bytes  16356954.00 bytes/sec
2012/01/04 03:19:14 [1461] total size is 81997177  speedup is 2.01


I believe this is what you want? Try your command without the --log-format option, and read the manual page for rsyncd.conf and search for "log format" to see what options you have to customize the logfile.

Another option I often use in my rsync scripts is to add date before/after the rsync, like:

date >> /var/log/rsync.log
rsync -avz --progress --delete /src /dst >> /var/log/rsync.log
date >> /var/log/rsync.log

And a third and final option would be to put your rsync command within a bash loop to prefix each line with the date.


If you want to see the time for every file on the rsync client, you need to use --out-format:

 rsync -avz --out-format="%t %f %b" remotehost:tmp . 

the output looks like this:

2013/01/11 10:57:41 tmp/foo.txt 210

Log Format String:

%t: time
%f: file
%b: transfered bytes

Replace >> /var/log/rsync.log replace with --log-file=/var/log/rsync.log -q