Jump to content

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


Recommended Posts

Posted

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?

Posted

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)

Posted (edited)
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.)

Edited by sparkeh
Posted

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

Posted
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.

Posted (edited)
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.

Edited by sparkeh
Posted
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.

Posted
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)
Posted
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 :(

Posted
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 :)

Posted
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 :)

Posted

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)

Posted

OK maybe not as much of a success as I thought

Few sixth formers in on the training day today, and half of their photoshop files have sort of 'lost' their file type and cant be opened by Photoshop. Its not all of them though which is strange

 

Thank god I kept the original folders on the old drive, so Ive reverted to them for now, but any ideas?

Posted
It's not copied the resource forks, as tar doesn't support them on 10.3, you need to use ditto, CpMac or MvMac according to wikipedia.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...