BackupPC-users

Re: [BackupPC-users] Different UID numbers for backuppc on 2 computers

2011-07-12 21:12:06
Subject: Re: [BackupPC-users] Different UID numbers for backuppc on 2 computers
From: Holger Parplies <wbppc AT parplies DOT de>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Wed, 13 Jul 2011 03:09:45 +0200
Hi,

Carl Wilhelm Soderstrom wrote on 2011-07-12 10:31:27 -0500 [Re: 
[BackupPC-users] Different UID numbers for backuppc on 2 computers]:
> On 07/12 12:34 , Holger Parplies wrote:
> > Carl Wilhelm Soderstrom wrote on 2011-07-11 17:19:09 -0500 [Re: 
> > [BackupPC-users] Different UID numbers for backuppc on 2 computers]:
> > > Then use a command like 'find / -uid 102 -exec chown backuppc: {} \;' to
> > > change the ownership of all the files owned by UID 102 to whatever UID
> > > backuppc is. 
> > 
> > Well I hope you don't have many files ... [...]
> > there shouldn't be any files belonging to backuppc elsewhere (check with
> > find) 
> 
> That's why I suggested checking the whole filesystem right away.

my point was that 'find -exec chown' spawns a process for each matching file it
encounters. If you've got a small or empty pool, that is no problem. If you've
got a large pool, that is simply a waste of your and your CPU's time. I
realize now (didn't think of that before) that each file with N links will
probably only be touched once, since after that it doesn't match '-uid 102'
anymore, so it's slightly less horrific than I first thought.

Still, if you can deal with the pool with a 'chown -R', that should be much
more efficient. After that, you can handle the potentially small number of
remaining files quite well with a 'find -exec chown' (and if you make 'find'
skip $TopDir, that's even better, though the directory information is possibly
still cached from the 'chown -R').

Of course, if you want to be *really* efficient, it's

        perl -MFile::Find -e '($u, $g) = (getpwnam ("backuppc")) [2, 3]; find 
(sub { chown $u, $g, $_ if (stat) [4] == 102; }, "/");'

(one process, one chown() syscall for each inode needing to be changed, one
recursive directory traversal), but, as you say, that's not something I'd post
without reading manual pages and trying it out on a limited area ;-).

For most cases, 'find | xargs' gets you far enough (you might argue that
'find -exec' does, too).

> 'chown backuppc: <filename>' will set the group to whatever the default
> group of the backuppc user is.

Ah, I didn't know that. Thank you for pointing that out.

> This may or may not be desireable in all cases, but it does save some
> keystrokes when it is desired.

The main benefit I see here is that backuppc's default group may or may not be
named 'backuppc' (probably is in most cases), so your version is simply always
correct while mine may not be.

> In any case, it is wise to try these sort of things out on a limited area if
> at all possible, and read the manual page before getting too fancy.

Right. But there's no reason not to get too fancy after having done that ;-).

Regards,
Holger

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/