in reply to maintaining owner id

perldoc -f chown should give you the info to set the files and directories ownership after creation.