|Keep It Simple, Stupid|
Preserving Ownership with File::Copy::Recursiveby xorl (Deacon)
|on Oct 11, 2012 at 12:03 UTC||Need Help??|
xorl has asked for the
wisdom of the Perl Monks concerning the following question:
I want to copy a directory (including subdirs) and preserve the ownership. This is a brief example that isn't working.
(while there is stuff in the bar directory, it doesn't seem to matter for this example)
And I get:
Looking at the documentation for File::Copy::Recursive, I don't see where it says anything about being able to preserve the ownership. My next thought is to try something combination of File::Find and File::Copy but that seems overly complex for something I think should be simple. Plus I don't see in the documentation where that would preserve ownership either.
So how should I go about recursively copying a directory while preserving ownership?
As noted in one of the replies, the script will be run by root.
Edit: Fixed typo and added more info
Edit #2: I'm giving up on a perl solution for now (but would still like to see one if it is possible). Going to write a bash script that uses either cp or maybe rsync instead.