currently I have an troublesome problem. I needed quite a time for identifying this problem. Anyhow that's what I'm doing:
I collect log files with rsync
from multiple servers to archive them. Its important to preserve the time attributes so I'm using the archive-mode of rsync
. But in some cases this leads to some errors.
The problem is that the log files are rotating (changing) on the servers.
So current logs that are in use are named like test.log
(they are not getting rsync
ed). After some time and/or a specific file size the log file is rotating. Meaning test.log
is renamed to test.log.1
. Now when test.log
is rotated again, test.log.1
is renamed to test.log.2
and test.log
is renamed to test.log.1
.
I think when test.log
would go directly to test.log.2
, there would be no problem. But that's something I cannot change.
And exactly this rotation happens somehow (sometimes) exactly when I'm rsync
ing. So rsync
get all the time-attributes of the files, then the rotation happens and then rsync
starts to collect the logfiles. But now for example test.log.1
isn't the same file anymore. But rsync
gets it anyway. In the end rsync
can't delete the file on the server because it changed (I see that in the rsync
debug). I hope that explanation makes sense.
So maybe a small process flow:
rsync
getting a file list with time-attributes (test.log.1
andtest.log.2
) (that's what I believe is happening, I don't know exactly how 'rsync' works)- the logs are rotating (
test.log.1
is now namedtest.log.2
and.2
now.3
) rsync
starts collecting (test.log.1
andtest.log.2
)rsync
can't delete the specific file
So is there any option that prevents that?