Operating System - HP-UX
1820552 Members
2045 Online
109626 Solutions
New Discussion юеВ

Preserving SGID with tar/gtar

 
Chern Jian Leaw
Regular Advisor

Preserving SGID with tar/gtar

HI,

I would like to transfer about 50GB of filesystems using a S-DLT tape.
From the man pages of tar/gtar, there does not seem to have any options of preserving the SGID or SUID.

Are there any other ways of preserving the SGID and SUID of these filesystem, besides gtar or tar for such data transfer?

If a script is required to automate such task, could someone kindly show how it's done?

Thanks.
4 REPLIES 4
John Carr_2
Honored Contributor

Re: Preserving SGID with tar/gtar

Hi

tar -p

this will preseve file ownerships and cause files files to be restored to there original modes and ownerships.

you could also consider using cpio to do this which is quicker than tar.

cheers
John.
Stefan Farrelly
Honored Contributor

Re: Preserving SGID with tar/gtar

By default tar restores SGID and SUID. Try it. Ive justed tested it, works fine. No special options needed.

Im from Palmerston North, New Zealand, but somehow ended up in London...
John Carr_2
Honored Contributor

Re: Preserving SGID with tar/gtar

Hi

If you have backed up your files with tar and when restoring them you encounter the SGID and SUID to be lost it may be because you are not root. System protections prevent the ordinary user from executing chown and chmod resulting in the error being ignored and the ownership being set to that of the restoring process. The SUID , SGID and stick bit information are restored as allowed by protections defined by chmod if the chown operation was successful.

cheers
John.
Manoj Misra
Advisor

Re: Preserving SGID with tar/gtar

Hi,

Use cpio, this is quicker and safer.
Regards
Manoj