Issue with rsync -R wrapped in a find command

findrsync

I'm trying to copy all the files named 'specials.xml' in the current and all subdirs, and also
create the name of each sub-directory. I'm using -R to rsync so it creates the relative paths for each corresponding subdirecotry. For example, I want cp:

/home/deploy/admin_xml_files/foo.com/specials.xml
/home/deploy/admin_xml_files/bar.com/specials.xml

to:

~/adminxml/foo.com/specials.xml
~/adminxml/bar.com/specials.xml

but this isn't working:

$ mkdir ~/adminxml/
$ find /home/deploy/admin_xml_files -iname 'specials.xml' -exec rsync -aR ~/adminxml/ {} +

It's saying:

ERROR: destination must be a directory when copying more than 1 file.
rsync error: errors selecting input/output files, dirs code 3) at
main.c(543) [Receiver=3.0.7]…

It's probably something to do with the argument order of rsync, since it needs to be SRC DEST

Best Answer

$ mkdir ~/adminxml/
$ cd /home/deploy/admin_xml_files
$ rsync -avR $(find . -iname 'specials.xml') /path/to/adminxml/
Related Topic