[opensuse] Question for rsync Experts: How to Mimic cp's --parents Option
Hi, The subject pretty much says it. I'd like to run rsync and get the effect that the --parents option has with cp. Specifically, that means that all leading directory components in the source arguments are replicated beneath the destination directory. Without this option, every distinct argument is placed directly in the destination directory using only it's base name (the portion following the right-most slash). Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Randall R Schulz wrote:
The subject pretty much says it. I'd like to run rsync and get the effect that the --parents option has with cp. Specifically, that means that all leading directory components in the source arguments are replicated beneath the destination directory.
I think the '--relative' option does that. rsync -avR /home/per/Documents <somedir> produces <somedir>/home/per/Documents /Per -- Per Jessen, Zürich (11.5°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Per Jessen pecked at the keyboard and wrote:
Randall R Schulz wrote:
The subject pretty much says it. I'd like to run rsync and get the effect that the --parents option has with cp. Specifically, that means that all leading directory components in the source arguments are replicated beneath the destination directory.
I think the '--relative' option does that.
rsync -avR /home/per/Documents <somedir>
produces
<somedir>/home/per/Documents
/Per
And pay attention to the trailing / as it has significance. man rsync gives more detail. -- Ken Schneider SuSe since Version 5.2, June 1998 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Per Jessen wrote:
Randall R Schulz wrote:
The subject pretty much says it. I'd like to run rsync and get the effect that the --parents option has with cp. Specifically, that means that all leading directory components in the source arguments are replicated beneath the destination directory.
I think the '--relative' option does that.
rsync -avR /home/per/Documents <somedir>
produces
<somedir>/home/per/Documents
/Per
In addition to relative, if you use the --files-from option, then the entire directory path is preserved and recreated on the destination machine. It doesn't matter how you create the file to take the actual files-from, but remember if you want recursive behavior on directories specified in the --files-from file, you must explicitly specify the -r option. Using --files-from is the only case where the -a option doesn't imply the -r option. An example of using --files-from would be: find /var/cache/zypp/packages -type f > rsynctmpfile rsync -uavr --files-from=rsynctmpfile / randall@destmachine.com:/ You can also tell it to create the exact dir structure below some other destination directory 'somedir' with: rsync -uavr --files-from=rsynctmpfile / randall@destmachine.com:/somedir I ran into this issue with the scripts for my local update repository, and I dang near *couldn't* keep rsync from copying /all/the/directory/info/before/file -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Friday April 3 2009, Randall R Schulz wrote:
Hi,
The subject pretty much says it. I'd like to run rsync and get the effect that the --parents option has with cp. ...
Thanks, gentlemen, the --relative option was what I wanted. I was aware of the trailing slash distinction. Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (4)
-
David C. Rankin
-
Ken Schneider - openSUSE
-
Per Jessen
-
Randall R Schulz