fracpete / rsync4j

Simple Java wrapper for rsync for Linux, OSX and Windows.

Home Page:https://fracpete.github.io/rsync4j/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rsync4j throws error when direct use of rsync doesn't (pattern in source)

retrofreak83 opened this issue · comments

I have the following issue:
I want to rsync files from the source having a certain pattern, let's say "*.inf" to my target directory.

So, the source is /home/sweet/home/s/*.inf
and the target is
/home/sweet/home/t.

When I do this using rsync4j, it fails with exit code 23 and the following error message:

rsync: link_stat "/home/sweet/home/s/*.inf" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]

When I use the command line options built by rsync4j and execute them manually in a shell, the command runs fine, though:

/usr/bin/rsync --recursive --links --times --compress --itemize-changes /home/sweet/home/s/*.inf /home/sweet/home/t

Any hints?

/home/sweet/home/s/*.inf most likely gets expanded by your shell. Instead of using *.inf in your source, just use the directory and use --include/--exclude. Something like this:

/usr/bin/rsync --recursive --links --times --compress --itemize-changes --include="*.inf" --exclude="*" /home/sweet/home/s /home/sweet/home/t

You can use methods Rsync.include(String...) and Rsync.exclude(String...) for that (order is relevant!).

NB: Haven't tested it.

That didn't work, but I meanwhile discovered that the legacy bash script I am to replace by a Java solution connects to a rsync daemon. I quickly set one up and tested again. There, patterns work as expected.

Thanks a lot for your support!