BackupPC-users

Re: [BackupPC-users] Smarter CGI

2011-05-17 20:59:04
Subject: Re: [BackupPC-users] Smarter CGI
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, 18 May 2011 02:57:58 +0200
Hi,

Bowie Bailey wrote on 2011-05-17 12:05:15 -0400 [Re: [BackupPC-users] Smarter 
CGI]:
> On 5/17/2011 9:11 AM, Steven Johnson wrote:
> > Greetings,
> > I would like to add some automation to the CGI interface. Firstly, in
> > the Xfer config screen for Rsyncd or SMB hosts, I would like to make the
> > Rsync/SmbShareName fields smarter so that when you click "add" you get a
> > selection box or dropdown menu of all available rsync/SMB shares. It will
> > use the username, password (and port for rsync) info to contact the host
> > for a list of shares (for rsync, those that are configured to "list" in
> > the rsync.conf file) Has anyone done something like this? is this even
> > possible?
> 
> Should be possible for Samba, not sure about rsync.

while I agree that this would be a nice feature for users of the GUI, you need
to keep several things in mind.

1.) The web server is not necessarily the host running BackupPC. In most
    cases it is (I presume), but it's not required. The web server may not
    have access to the backup clients. Even the BackupPC server may not
    have access to the backup clients without running the PreDump command
    (which might set up an ssh tunnel, VPN, etc.), and running the PreDump
    command is not generally a good idea when you're not about to do a
    backup, because it might do anything (create database dumps ...). The
    point is, BackupPC allows quite complex scenarios, and some people use
    them.

    So, it might work in some cases, but it won't work in all cases. That
    means, if it doesn't work, you can't use the GUI for configuration.

    On the other hand, administrators of complex setups are probably more
    likely to use their favorite vi clone for configuring BackupPC anyway ;-).

2.) You're letting a web access initiate a command that needs to be run as
    the backuppc user (access to the ssh identities). You need to be *very*
    careful about how you do that, lest you open up security holes. You might
    think of the simple cases (e.g. someone passing a host name like

            host"; rm -rf /var/lib/backuppc; echo "

    as parameter), but which cases won't you think of?

3.) People might want (or need) to set up the backup configuration *before*
    configuring the client hosts. If you have a dropdown menu, you can't
    enter values the menu doesn't contain.
    I'm not sure if that's possible with rsyncd/smb, but if it is, you might
    also want to use subdirectories of module names as BackupPC "share" name.
    That would also not be possible.

    Of course, if you can code up some smart completion suggestion mechanism
    (like you have, for example, on the google web page search input field),
    that would allow inputting any arbitrary value while giving you sensible
    suggestions (when available). But please test that on all browsers ;-).

4.) What if the client host is offline when you are changing the
    configuration?

5.) What if the connection to the client host is extremely slow or expensive
    to set up (dial on demand)? Do you need to wait - possibly encountering
    a browser timeout - for your configuration page, even if you don't *want*
    to change a relevant setting? (Sorry, I don't use the GUI, that last part
    may not apply.)

6.) You need to make sure that all relevant parts of the configuration have
    been filled out before (e.g. ClientNameAlias, SmbClientFullCmd - from
    which you would need to figure out how to list the shares; there's a
    reason this setting is configurable in BackupPC).

All in all, I'd prefer a new (per-host) configuration variable GuiListShares
which would point to a script which could do *anything* to figure out the list
of share names (e.g. print static strings to stdout). Leaving this setting
empty (or even the command not returning any share names) would give you a
text input field like now. Invocation of the command should be via the
BackupPC server (BackupPC_serverMesg), though I'm not sure serverMesgs can
be completed asynchronously (well, the child process running the command
could be set up with stdout pointing to the socket; the server process
could simply close its descriptor and forget about the matter; not much
error logging in this case, though, and it wouldn't really fit in with
the existing serverMesg commands).

Of course this would mean that before configuring the shares, you'd have to
configure how to get a list of shares, which might, to a certain extent,
defeat the purpose. But if you have a global script
"list_shares.pl <host> <xferMethod>" and a global config setting, then you
would achieve what you are suggesting: automation. A version of this script
for "simple, normal cases" could even be distributed with BackupPC or through
the wiki. And, you wouldn't be limited to certain xferMethods, presuming you
can figure out "share names" for the other types (maybe mount points on the
client host?).

> > Lastly, for various fields throughout the CGI, I would like to make them
> > drop down menu's with pre-populated options. [...]
> 
> This should be simply a matter of changing the type of html field being
> used to collect the data.  Theoretically, all you would have to do is
> find the spot in the code where it generates the config screen and
> change it there.  Of course, I'm not familiar with the code, so it is
> possible there is something else involved.

Localization? Oh, it should work, it's just probably more work than you'd
first expect. I'm not really familiar with the code either, but if you're
lucky, it's just exchanging one constant HTML fragment for another (possibly
composed of several language-dependent parts), and if you're unlucky, you'll
have to put a "selected" option in the correct place.

You're bound to get help for that one, because it would really make the GUI
better. Nice idea.

Regards,
Holger

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
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/

<Prev in Thread] Current Thread [Next in Thread>