+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
Mac Thread, How do you copy a folder and preserve ownership/permissions? in Technical; Fitted a new drive, copied a year groups folder over, now when I look at each pupils folder its defaulted ...
  1. #1

    Join Date
    Jul 2006
    Location
    London
    Posts
    2,962
    Thank Post
    160
    Thanked 152 Times in 116 Posts
    Rep Power
    49

    How do you copy a folder and preserve ownership/permissions?

    Fitted a new drive, copied a year groups folder over, now when I look at each pupils folder its defaulted to being owned by admin. I dont really want to go through them all again, so how can you copy and keep all permissions.

    I assume its really easy to do with the command line but Im not that experianced with osx yet...is there a GUI way?

  2. #2

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,035
    Thank Post
    1,374
    Thanked 1,780 Times in 1,200 Posts
    Blog Entries
    22
    Rep Power
    531
    Hmm...making a tar then moving it, then untar will preserve permissions.

    Working off the top of my head but something like:

    % tar cpf - inputdir | (cd /Users/someone/archive/stuff; tar xpf -)

    should do it? (the p flag preserves permissons)

  3. #3
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,487
    Thank Post
    10
    Thanked 502 Times in 442 Posts
    Rep Power
    114
    cp -p should do it

  4. #4

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,035
    Thank Post
    1,374
    Thanked 1,780 Times in 1,200 Posts
    Blog Entries
    22
    Rep Power
    531
    Quote Originally Posted by DMcCoy View Post
    cp -p should do it
    Really? Im not convinced that will work with Mac files (could be wrong but I would use the tar method to make sure.)
    Last edited by sparkeh; 17th April 2008 at 11:53 AM.

  5. #5

    Join Date
    Jul 2006
    Location
    London
    Posts
    2,962
    Thank Post
    160
    Thanked 152 Times in 116 Posts
    Rep Power
    49
    Well Ill try the cp method first

    I cant seem to get anything to copy though, am I doing this right?

    cp -p Constable Volumes/"Data 2"/Constable

    I dont get any error messages from that, but nothing seems to copy either
    When I type that Im in Volumes/Data 1 and Constable is the folder, Ive also created a folder called Constable on Data 2

  6. #6
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,487
    Thank Post
    10
    Thanked 502 Times in 442 Posts
    Rep Power
    114
    Quote Originally Posted by sparkeh View Post
    Really? Im not convinced that will work with Mac files (could be wrong but I would use the tar method to make sure.)
    it will even copy any ACLs and resource forks you may have, most of the unix tools have been modified on os x to support apple specific features.

  7. #7

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,035
    Thank Post
    1,374
    Thanked 1,780 Times in 1,200 Posts
    Blog Entries
    22
    Rep Power
    531
    Quote Originally Posted by DMcCoy View Post
    it will even copy any ACLs and resource forks you may have, most of the unix tools have been modified on os x to support apple specific features.
    Oh from past experience, if cp comes across any files with resources then you can get problems, like resource forks being deleted. Perhaps things have changed.
    Last edited by sparkeh; 17th April 2008 at 12:17 PM.

  8. #8
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,487
    Thank Post
    10
    Thanked 502 Times in 442 Posts
    Rep Power
    114
    Quote Originally Posted by sidewinder View Post
    Well Ill try the cp method first

    I cant seem to get anything to copy though, am I doing this right?

    cp -p Constable Volumes/"Data 2"/Constable

    I dont get any error messages from that, but nothing seems to copy either
    When I type that Im in Volumes/Data 1 and Constable is the folder, Ive also created a folder called Constable on Data 2
    Something like this if you want subfolders copied too

    cp -p -R /Volumes/RAIDA/Custom /Volumes/RAIDB/

    this copies the Custom folder from /Volumes/RAIDA/ to /Volumes/RAIDB

    The -R is for recursive, but as sparkeh mentioned it will mess with things like links, as I don't have any on my user home folders I've moved all their data around a few times with cp.

  9. #9
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,487
    Thank Post
    10
    Thanked 502 Times in 442 Posts
    Rep Power
    114
    I should point out that this applies to 10.4 and above only. 10.3 unix tools don't copy resource forks and other things, so something like tar should be used (if it does support them in 10.3)

  10. #10

    Join Date
    Jul 2006
    Location
    London
    Posts
    2,962
    Thank Post
    160
    Thanked 152 Times in 116 Posts
    Rep Power
    49
    Aha I was about to say, it all copied but permissions all set to default...and Im on 10.3
    Will try the tar method then
    At least Ive learned something new!

  11. #11
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,487
    Thank Post
    10
    Thanked 502 Times in 442 Posts
    Rep Power
    114
    Quote Originally Posted by sidewinder View Post
    Aha I was about to say, it all copied but permissions all set to default...and Im on 10.3
    Will try the tar method then
    At least Ive learned something new!
    Aparently according to wikipedia

    "Until the advent of Mac OS X v10.4, the standard UNIX command line utilities in Mac OS X (such as cp and mv) did not respect resource forks. To copy files with resource forks, one had to use ditto or CpMac and MvMac."

    I'm afraid 10.4 is *SO* much better than 10.3, with, well - everything. Much better AD support, ACLs etc. 10.3 is a bit rubbish

  12. #12

    Join Date
    Jul 2006
    Location
    London
    Posts
    2,962
    Thank Post
    160
    Thanked 152 Times in 116 Posts
    Rep Power
    49
    Quote Originally Posted by DMcCoy View Post
    Aparently according to wikipedia

    "Until the advent of Mac OS X v10.4, the standard UNIX command line utilities in Mac OS X (such as cp and mv) did not respect resource forks. To copy files with resource forks, one had to use ditto or CpMac and MvMac."

    I'm afraid 10.4 is *SO* much better than 10.3, with, well - everything. Much better AD support, ACLs etc. 10.3 is a bit rubbish
    Yeah its frustrating, keep reading about different things but cant do any of it because we're on 10.3
    New server on its way soon though with 10.5 so dont have to put up with it for long

  13. #13

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,035
    Thank Post
    1,374
    Thanked 1,780 Times in 1,200 Posts
    Blog Entries
    22
    Rep Power
    531
    Quote Originally Posted by DMcCoy View Post
    Aparently according to wikipedia

    "Until the advent of Mac OS X v10.4, the standard UNIX command line utilities in Mac OS X (such as cp and mv) did not respect resource forks. To copy files with resource forks, one had to use ditto or CpMac and MvMac."

    I'm afraid 10.4 is *SO* much better than 10.3, with, well - everything. Much better AD support, ACLs etc. 10.3 is a bit rubbish
    Ah right yes, 10.3 was the last time I seriously used a Mac. Glad I'm not going mad

  14. #14

    Join Date
    Jul 2006
    Location
    London
    Posts
    2,962
    Thank Post
    160
    Thanked 152 Times in 116 Posts
    Rep Power
    49
    oh ffs lol
    Tried the tar method
    All copied fine, but again no permissions!

    I typed:

    tar cpf - /Volumes/DATA1/Constable | (cd /Volumes/DATA2/tartest; tar xpf -)

    Anything wrong with that?

    (btw in case you're wondering I changed the volume names because I didnt want to keep having to put " round them)

  15. #15

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,035
    Thank Post
    1,374
    Thanked 1,780 Times in 1,200 Posts
    Blog Entries
    22
    Rep Power
    531
    Ummmmm....

    Are you doing this as root? Not clear that this would make a difference but worth a try?



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. VBS Script to copy a folder
    By FN-GM in forum Scripts
    Replies: 2
    Last Post: 23rd February 2008, 02:08 PM
  2. User drive permissions and ownership
    By OutLawTorn in forum Scripts
    Replies: 0
    Last Post: 30th November 2007, 01:15 AM
  3. Ownership and Permissions
    By TechSupp in forum How do you do....it?
    Replies: 2
    Last Post: 5th October 2007, 11:38 PM
  4. Got a folder I cannot delete or take ownership of
    By sidewinder in forum Windows
    Replies: 2
    Last Post: 20th March 2007, 03:49 PM
  5. Replies: 6
    Last Post: 20th October 2005, 07:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •