LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can I maintain ownership copying from one machine to another? (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-maintain-ownership-copying-from-one-machine-to-another-663824/)

laggerific 08-19-2008 08:47 AM

How can I maintain ownership copying from one machine to another?
 
I have taken a snapshot of a rhel4 system and booted it on another system, but one of the filesystems I need to manually recreate by copying it from the old system to the new system. Since these systems are identical, all the users and their UIDs should be the same.

How can I copy from one machine to the other and maintain both permissions and ownership? Could I use RSync? If I've already copied the data while maintaining the permission structure (but not the ownership) can I just rsync the data to fix the permissions, or will that just recopy the file, or just ignore it all together?

Any help on this topic would be greatly appreciated!

Thank you.

MensaWater 08-19-2008 08:55 AM

tar stores the UIDs so bundling it and copying over would work so long as the UIDs on target system are same.

rsync does preserve owner, group, permissions, times etc... There are flags for most of these but the short cut that usually works is:

cd to the directory you want to copy then run:
rsync -avz -e ssh ./ root@targethost:/targetdir

The -a is archive which implies most of the flags needed to keep the copies exactly the same. The -v is verbose and the -z compresses before transfer and uncompresses on target. The -e ssh tells it to use ssh for the shell.

laggerific 08-19-2008 11:04 AM

fantastic...I had already been tarring over SSH, but didn't do it as root on the destination system, so the perms didn't transfer. But, using the rsync command supplied with root this time, I was able to fix the perms in seconds without the need to resend all data. Thank you for your timely information.


All times are GMT -5. The time now is 07:07 AM.