5

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?

2
  • 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. Commented Dec 22, 2014 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. Commented Dec 22, 2014 at 19:50

1 Answer 1

5

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.