In rsync, --log-file creates a log file, however, if i do a daily backup, the log is appended to the previous log file. How can i force rsync to overwrite the log file instead of appending to it?

  • 1
    COuldn't you just delete it before starting the next backup? Though moving it out of the way (possibly using logrotate) might be better. – Faheem Mitha Dec 22 '14 at 18:35
  • I thought of adding a line to delete it in the crontab but did not like it as a solution and i thought i leave this as a last resort. – Fawzi Masri Dec 22 '14 at 19:50

The answer is that you cannot (unless you compile your own rsync binary).

rsync always appends to the log file. So as suggested in the comments you should delete the log before running rsync. A simple example of removing the log and then running rsync is:

rm rsync.log; rsync [OPTION...] SRC... [DEST]

These might also be helpful:

  1. https://serverfault.com/questions/219440/rsync-via-cron-how-do-i-enable-logging
  2. https://superuser.com/questions/545642/is-it-possible-to-make-rsync-make-a-log-file-on-a-remote-system
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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