0

I have a remote server that is continuously generating log files and saving them to a directory. Unfortunately, the log files are generated at random times, so you can't predict when the next logfile will be available.

I have a second server (Ubuntu 18.04.6 LTS) that has SSH connectivity to the log-generating machine. For reasons too complex to detail here, I need the second server to automatically copy all those log files to its own local hard drive. The second server will do some processing on the logs, then must delete those locally-saved logs to save on disc space. A logfile only needs to be processed once.

The problem: Server #2 has to periodically log into Server #1 and copy only the logfiles that have been generated since its last check-in. RSYNC could do this in a pinch, except...

...Server #2 deletes the logfiles that it downloaded previously. I believe that Rsync needs those local logfiles to be intact, or else how would it know what new files have been created since its last visit?

Does anyone know of a way to do this with RSYNC? I've looked through the delete options and don't see any obvious solution. Thank you.

Pete
  • 131
  • 6
  • 1
    `--remove-source-files` This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side. Note that you should only use this option on source files that are quiescent. [source](https://explainshell.com/explain?cmd=rsync%20--remove-source-files#:~:text=%2D%2Dremove%2Dsource%2Dfiles%20This,source%20files%20that%20are%20quiescent.) – djdomi Sep 01 '22 at 17:35
  • @djdomi Thanks Djdomi. Question: would `--remove-source-files` actually delete the files on the remote server? Because I don't want to alter that server at all, only copy its data. Thank you! – Pete Sep 01 '22 at 18:05

0 Answers0