0

I am looking for a way to copy uids and gids for all files of a directory tree from one machine to another. The directory tree is believed to be identical on both machines except that uids and gids got corrupted on the target machine.

The background is that I copied the tree with rsync some months ago, thereby erronously omitting the --numeric-ids option, which caused uids and gids to be wrong in the destination.

Something like

find . -printf "chown %U.%G '%p'\n"

that still works for file names that contain special characters, whitespace, and quotes.

  • Why don't you just run rsync again? – Michael Hampton May 31 '21 at 20:41
  • Basically the backup tree is so large that the rsync runs several hours, so I was hoping for a quicker solution. – Helmut Emmelmann May 31 '21 at 21:14
  • The misbehaved rsync run was several month ago. So I was not sure that the directories on both machines were 100% identical (I plan to clarify that by editing the question). Thanks to Michael Hampton's comment, I tried with rsync in a dry run and grepped the resulting log files to verify that rsync does nothing else but fixing the ids. Since this was the case, a following non-dry run worked fine and fast (after disabeling --checksum) solving my problem. Maybe still s.o. has a different solution, that avoids grepping the logs or that tolerates changes in the the target directory. – Helmut Emmelmann Jun 02 '21 at 11:36

0 Answers0