Clone ownership and group of coincident name files and folders between two servers
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I need to sync only ownership and group of each file and dir between two server filesystems. That's to say if I have server A and server B, I don't need and don't want to copy data from one server to other, I need to set the same owner and group from each file in B that exists in A. If a file/dir doesn't exist in A, or viceversa, I don't need to do nothing about, only to change owner and group of every file and directory that exists in both servers to the one of the file/dir in server A. I know that "chown --reference
" make that, but I don't know how to use it for change according to other files and directories.
I wish I explained my question correctly.
Please, any suggestion?
Thanks in advance
group synchronization ownership
add a comment |Â
up vote
1
down vote
favorite
I need to sync only ownership and group of each file and dir between two server filesystems. That's to say if I have server A and server B, I don't need and don't want to copy data from one server to other, I need to set the same owner and group from each file in B that exists in A. If a file/dir doesn't exist in A, or viceversa, I don't need to do nothing about, only to change owner and group of every file and directory that exists in both servers to the one of the file/dir in server A. I know that "chown --reference
" make that, but I don't know how to use it for change according to other files and directories.
I wish I explained my question correctly.
Please, any suggestion?
Thanks in advance
group synchronization ownership
Just owner and group, and neither permission nor SELinux security context nor ACLs? (Just checking.)
â Ulrich Schwarz
Feb 8 at 8:24
Yes, only OWNER and GROUP, not data content or permissions
â Rafael Linux User
Feb 8 at 8:28
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need to sync only ownership and group of each file and dir between two server filesystems. That's to say if I have server A and server B, I don't need and don't want to copy data from one server to other, I need to set the same owner and group from each file in B that exists in A. If a file/dir doesn't exist in A, or viceversa, I don't need to do nothing about, only to change owner and group of every file and directory that exists in both servers to the one of the file/dir in server A. I know that "chown --reference
" make that, but I don't know how to use it for change according to other files and directories.
I wish I explained my question correctly.
Please, any suggestion?
Thanks in advance
group synchronization ownership
I need to sync only ownership and group of each file and dir between two server filesystems. That's to say if I have server A and server B, I don't need and don't want to copy data from one server to other, I need to set the same owner and group from each file in B that exists in A. If a file/dir doesn't exist in A, or viceversa, I don't need to do nothing about, only to change owner and group of every file and directory that exists in both servers to the one of the file/dir in server A. I know that "chown --reference
" make that, but I don't know how to use it for change according to other files and directories.
I wish I explained my question correctly.
Please, any suggestion?
Thanks in advance
group synchronization ownership
asked Feb 8 at 8:17
Rafael Linux User
162
162
Just owner and group, and neither permission nor SELinux security context nor ACLs? (Just checking.)
â Ulrich Schwarz
Feb 8 at 8:24
Yes, only OWNER and GROUP, not data content or permissions
â Rafael Linux User
Feb 8 at 8:28
add a comment |Â
Just owner and group, and neither permission nor SELinux security context nor ACLs? (Just checking.)
â Ulrich Schwarz
Feb 8 at 8:24
Yes, only OWNER and GROUP, not data content or permissions
â Rafael Linux User
Feb 8 at 8:28
Just owner and group, and neither permission nor SELinux security context nor ACLs? (Just checking.)
â Ulrich Schwarz
Feb 8 at 8:24
Just owner and group, and neither permission nor SELinux security context nor ACLs? (Just checking.)
â Ulrich Schwarz
Feb 8 at 8:24
Yes, only OWNER and GROUP, not data content or permissions
â Rafael Linux User
Feb 8 at 8:28
Yes, only OWNER and GROUP, not data content or permissions
â Rafael Linux User
Feb 8 at 8:28
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
Assuming that you don't mind trying to set ownerships on files that already have them correctly, I guess you could run something along the lines of
/bin/stat --format 'chown %u:%g %n' ~/.bash*
on server A, which will give you a list of chown
commands to execute on server B. (You could pipe the whole thing through | ssh user@serverB
.)
You'll get the occasional error for files that don't exist on B, but that would be harmless.
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
@RafaelLinuxUser, trystat --format 'chown %U:%G "%n"'
to have names
â JJoao
Feb 8 at 8:54
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
1
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Assuming that you don't mind trying to set ownerships on files that already have them correctly, I guess you could run something along the lines of
/bin/stat --format 'chown %u:%g %n' ~/.bash*
on server A, which will give you a list of chown
commands to execute on server B. (You could pipe the whole thing through | ssh user@serverB
.)
You'll get the occasional error for files that don't exist on B, but that would be harmless.
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
@RafaelLinuxUser, trystat --format 'chown %U:%G "%n"'
to have names
â JJoao
Feb 8 at 8:54
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
1
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
 |Â
show 1 more comment
up vote
2
down vote
Assuming that you don't mind trying to set ownerships on files that already have them correctly, I guess you could run something along the lines of
/bin/stat --format 'chown %u:%g %n' ~/.bash*
on server A, which will give you a list of chown
commands to execute on server B. (You could pipe the whole thing through | ssh user@serverB
.)
You'll get the occasional error for files that don't exist on B, but that would be harmless.
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
@RafaelLinuxUser, trystat --format 'chown %U:%G "%n"'
to have names
â JJoao
Feb 8 at 8:54
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
1
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
 |Â
show 1 more comment
up vote
2
down vote
up vote
2
down vote
Assuming that you don't mind trying to set ownerships on files that already have them correctly, I guess you could run something along the lines of
/bin/stat --format 'chown %u:%g %n' ~/.bash*
on server A, which will give you a list of chown
commands to execute on server B. (You could pipe the whole thing through | ssh user@serverB
.)
You'll get the occasional error for files that don't exist on B, but that would be harmless.
Assuming that you don't mind trying to set ownerships on files that already have them correctly, I guess you could run something along the lines of
/bin/stat --format 'chown %u:%g %n' ~/.bash*
on server A, which will give you a list of chown
commands to execute on server B. (You could pipe the whole thing through | ssh user@serverB
.)
You'll get the occasional error for files that don't exist on B, but that would be harmless.
answered Feb 8 at 8:30
Ulrich Schwarz
8,87512643
8,87512643
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
@RafaelLinuxUser, trystat --format 'chown %U:%G "%n"'
to have names
â JJoao
Feb 8 at 8:54
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
1
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
 |Â
show 1 more comment
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
@RafaelLinuxUser, trystat --format 'chown %U:%G "%n"'
to have names
â JJoao
Feb 8 at 8:54
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
1
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
I don't mind to "re-set" files that have yet the correct owner and group, as you correctly thought. I think your idea is fantastic, I didn't imagine to use "stat". I was wondering on using "rsync" combined with "chown --reference", but your solution is less risky. I'll give you news about the task. Thank you!!
â Rafael Linux User
Feb 8 at 8:40
@RafaelLinuxUser, try
stat --format 'chown %U:%G "%n"'
to have namesâ JJoao
Feb 8 at 8:54
@RafaelLinuxUser, try
stat --format 'chown %U:%G "%n"'
to have namesâ JJoao
Feb 8 at 8:54
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Thank you!! I remove my question, cause I should have investigate more on the paremeters of "stat" before asking.
â Rafael Linux User
Feb 8 at 9:27
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
Based on Ulrich solution, I have this sentence: "find / ! -user root -or ! -group root | xargs stat --format 'chown %U:%G %n' ", but , please, how to redirect to a txt file? I tried adding "> text.txt" but didn't worked.
â Rafael Linux User
Feb 8 at 9:29
1
1
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
@JJoao: yes, always a tricky issue if you don't know if uid/guid assignments are the same for both servers.
â Ulrich Schwarz
Feb 8 at 11:57
 |Â
show 1 more comment
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422728%2fclone-ownership-and-group-of-coincident-name-files-and-folders-between-two-serve%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Just owner and group, and neither permission nor SELinux security context nor ACLs? (Just checking.)
â Ulrich Schwarz
Feb 8 at 8:24
Yes, only OWNER and GROUP, not data content or permissions
â Rafael Linux User
Feb 8 at 8:28