Rsync skip existing files on source

I am developing a script in python that can collect logs from multiple computers. I am using rsync. But there is a problem. I have logs for several services that look like this:

service1.log service2.log service3.log ... and so on 

The paths to these files and folders are indicated in the code. But sometimes I get a situation where some log files do not exist yet. And rsync will not complete successfully.
How can I skip files that do not exist on the source computer?
Postscript I use saltstack to control the machines, so I call:

 __salt__['cmd.retcode']('rsync -a file1 file2...') 
+7
python linux rsync
source share
1 answer

Use --ignore-missing-args :

The manual page version 3.1.0 says:

- ignore missed-arg

  When rsync is first processing the explicitly requested source files (eg command-line arguments or --files-from entries), it is normally an error if the file cannot be found. This option suppresses that error, and does not try to transfer the file. This does not affect subsequent vanished-file errors if a file was initially found to be present and later is no longer there. 

For example:

 % rsync --version rsync version 3.1.0 protocol version 31 % rsync bogusfile dest rsync: link_stat "/tmp/bogusfile" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0] % rsync --ignore-missing-args bogusfile dest # <no error> 

The --ignore-missing-args been added some time between version 3.06 and 3.1.0.

the online version 3.06 rsync man does not mention this. But the git repository indicates that this option was added in 2009.

+11
source share

All Articles