Hi Darien,

On Thursday 26 April 2007 writes Darien Hager:
> On Apr 24, 2007, at 11:38 PM, Falk Sauer wrote:
> > On Wednesday 25 April 2007 writes Ross Boylan:
> >> Does anyone know of a tool/script that will remap one set of uid's
> >> and
> >> gid's to another?  I.e., if sarah has id 1005 on the original system,
> >> and I restore it to a system where sarah has id 1004, can I get
> >> something that will rewrite the id's on the new system to 1004.
> >
> > You can use find for your opinion:
> >
> > find /path/to/your/restore/ -uid 1021 -exec chown newuser.newgroup
> > {} \;
>
> The problem with a naive find is that you may be trying to remap UIDs
> where the old set and the new set have collisions, for exmaple:
> UID 5 -> UID 7
> UID 7 -> UID 5
>
> In this case we need some way of knowing which files have already had
> their ownerships changed.
>
> One way is to combine the change with a move from one directory to
> another.

a other way is to use a unused uid (chown can also eat numbers
'chown 0 file' sets the file owner to root)

UID5 -> UID99
UID7 -> UID5
UID99 -> UID7

this is the classical recipe and you must nothing 'remember' which files you 
already changed. ;-)

> Another is to create/touch a new temporary file, and use that file
> with a negated "-cnewer" argument to find. That way find only returns
> files which have not been changed since you made the tempfile.
> ("Changed" is updated on permission or file change, "modified" is
> only for data change.)
>
>       touch /path/to/tempfile
>       find /path/to/your/restore/ -uid 1234 -not -cnewer '/path/to/
> tempfile' -exec "chown newuser.newgroup {}"

if you also must deal with the original timestamps from the original file do 
like this:

 touch "$DATA_PATH/.timestamp" -r "$DATA_PATH/interesting.file"
 do anything with interesting.file 
 touch "$DATA_PATH/interesting.file" -r "$DATA_PATH/.timestamp"

the unix toolbox inherit all what you need.

regards
   Falk


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to