BackupPC-users

Re: [BackupPC-users] host config file command line editor ?

2009-01-08 23:53:17
Subject: Re: [BackupPC-users] host config file command line editor ?
From: Holger Parplies <wbppc AT parplies DOT de>
To: Alex <backuppc-forum AT backupcentral DOT com>, alexandre AT inforeseau DOT com
Date: Fri, 9 Jan 2009 05:50:01 +0100
Hi,

Alex wrote on 2009-01-08 10:41:35 -0500 [[BackupPC-users]  host config file 
command line editor ?]:
> i'm not aware using Perl scripting, but ok with bash / php.

learn Perl, it's much more fun :-).

> Then, i'd like to know if there's a way to set values for per pc config
> file using command line tool ?

'vi host.pl' ?

> By exemple, like to change only FullKeepCnt value, but, has it is by default
> written that way :
> $Conf&#123;FullKeepCnt&#125; = &#91;
> &nbsp; '400'
> &#93;;
> 
> It's a bit hard for me to parse this file and write back a new value. 

I can see why that would be ...

> [...] I'd like to be able to do that kind of thing without de cgi web
> interface, in order for me to be able to change values through scripts.

Well, I don't know of any existing tool. It much depends on what you want to
do and be able to do.

- Can you guarantee that the host.pl files will never be modified through
  the web interface?
- Do you want to keep comments etc. in the host.pl files or just the settings?
- How do you suggest setting anything more complex than a simple string value
  (arrays, hashes, hashes of arrays)?
- BackupPC may accept different types of values for one parameter.
  BackupFilesExclude, for example, can be a string, an array of strings, or a
  hash of arrays of strings. Do you want to handle all cases correctly?

Depending on your answers, you could re-format your host.pl files to put each
assignment on one line (with some tending to get rather long) and then use
'sed' to modify them, do some "perl -e 'use Data::Dumper; ...'"-magic (I
started a small script but dropped it when the array question came up) ... you
could probably even use BackupPC::CGI::EditConfig, though I doubt emulating a
CGI POST request and supplying all the values is what you really had in mind.

Actually, I just added another few lines to the script for handling the first
hash/array cases that spring to mind, as well as removing values. It's not
extensively tested, but since I quick-hack(tm)ed it, I might as well include
it, just in case it fits anyone's needs. I'm not going to use it myself, as
I'd like to preserve comments in my config files.

Questions as to how to use it will be answered if posted to the mailing list
directly ;-). For the beginning, try

        BackupPC_editconf.pl -f /etc/backuppc/testhost.pl FullKeepCnt=399 
'BackupFilesExclude{/}[0]=/sys'

Attachments can apparently not be accessed via Backup Central, which doesn't
really bother me. See the real mailing list archive instead:

http://sourceforge.net/mailarchive/forum.php?thread_name=1231429295.m2f.295958%40www.backupcentral.com&forum_name=backuppc-users

Regards,
Holger

Attachment: BackupPC_editconf.pl
Description: Text Data

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
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/