Logging RSYNC output to file can be cumbersome but useful at times. Cumbersome because if you’re transferring a large number of files then the log file becomes intelligible but useful in cases where you need to track successful vs. unsuccessful transfers. You can use the logged output of RSYNC to track which files were able to successfully transfer over from a drive ridden with bad sectors, a scenario we had to go through recently. With a list of failed files, we at least have an idea of how much data was lost and what exactly was lost.
At first, we tried appending the verbose output of RSYNC using the following technique:
This worked partially, it only logged the successful transfer messages, not the failures. We tried the following next:
Using this we were able to get a log file which listed both successful and unsuccessful transfers, simply grepped to get a list of unsuccessful ones.