PApp

 view release on metacpan or  search on metacpan

bin/agni  view on Meta::CPAN


	agni --file /tmp/config.xml --import-path root/agni/staging/data/

This command imports the data that we previously exported back into agni
with the same path information.

=head2 Exporting whole images for backup purposes

	agni --save-image /backuppath/backup.xml

This exports a complete backup of the running system to an image file
F</backuppath/backup.xml>.

Please take into account that some distributions clear their F<tmp>
directories after a reboot and thereby render F</tmp> an unwise choice
for the backup directory!

=head2 Importing the previously created backup

	agni --load-image /backuppath/backup.xml

This command imports the previously saved image into agni, overwriting
all existing data.

=head2 Executing a command inside agni

	agni -e root/agni/staging/data/ call ra/settings::class ra_upgrade

This command calls a method in object F<ra/settings::class>, agni-path
B<root/agni/staging/data/> called B<ra_upgrade>. Use this feature with
caution!

To give the method call arguments simply write them on the command line:

	agni -e root/agni/staging/nethype_data/ call mercury_nethype/report::own_summary summary 0 2141167600

This calls the summary method on the report::own_summary object with the two arguments
0 and 2141167600 (unix timestamps btw.).

=head1 COPYRIGHT

Copyright (C) 2003,2004 nethype GmbH, Franz-Werfel-Str. 11, S<74078
Heilbronn>.

This Program is part of the PApp!Agni Distribution. Usage
requires a valid license.

=head1 AUTHOR

Marc Lehmann <marc@nethype.de>,
Marco Maisenhelder <marco@nethype.de>,
L<http://www.nethype.de/agni>

=cut

use Getopt::Long;

use PApp;
use PApp::Config ();
use PApp::SQL;
use PApp::XML qw(xml_quote xml_attr xml_tag xml_cdata);
use PApp::Util qw(dumpval); # debug#d#
use PApp::Event ();
use MIME::Base64;
use Convert::Scalar qw(utf8_valid);

use Agni;

my $opt_force;

sub do_some_tests {
   warn "heiheihei\n";#d#
   #my $vo = path_obj_by_gid 1, 783;
   #warn PApp::Util::dumpval($vo->{_content});
   #warn "hoiheihei\n";#d#
   #$vo->{_type}{content}->fetch($vo);
   #$vo->show_content;
   #(path_obj_by_gid 1, 5100000652)->show_content;
   local $Agni::debug=1;
   #my $o1 = path_obj_by_gid 1,5100000482;
   my $o1 = path_obj_by_gid 1,5100000016;
   warn PApp::Util::dumpval($o1->{_cache});
   exit;
   my $path = 3;
   my $t1 = Time::HiRes::time;
   my $customer = path_obj_by_gid $path, 5100000422;
   my $lg = path_obj_by_gid $path, 5100000420;
   my $us = path_obj_by_gid $path, 17180000071;
   my $t2 = Time::HiRes::time;
   warn $t2-$t1;
}

sub quote_attr($) {
   local $_ = $_[0];
   s/^/\t/gm;
   $_ = "\n$_\n    ";
   xml_cdata $_;
}

sub print_attr {
   my ($fh, $type, $data) = @_;

   my $encode = !utf8_valid $data || $data =~ /[\x{0}-\x{8}\x{b}\x{c}\x{e}-\x{1f}]/;

   print $fh "\n    ",
             (xml_tag "a",
                 type => $type,
                 $encode ? (base64 => "yes") : (),
                 defined $data
                    ? (length $data) < 30 && $data !~ y/a-zA-Z0-9_:\-$, //c
                       ? (value => $data, undef)
                       : ($encode
                          ? "\n" . (encode_base64 $data) . "    "
                          : quote_attr $data)
                    : (null => "yes", undef));
}

my %import_ignore_type;

sub parse_objects {
   my ($file) = @_;
   my @end;
   my @data;
   my @objs;
   my @paths;
   my ($o, $all);
   my @map_path;
   my %map_path;
   my $in_o;

   require XML::Parser::Expat;

   my $parser = new XML::Parser::Expat;
   $parser->setHandlers(
      Start => sub {
         shift;
         push @end, do {
            if ($_[0] eq "database" or $_[0] eq "image") {
               shift;
               my %a = @_;
               die "unsupported version '$a{version}'" if $a{version} != 1;
               sub { }
            } elsif ($_[0] eq "path") {
               shift;
               @data = ();
               my %a = @_;
               my $id = $a{id};
               sub {
                  push @paths, join "", @data;
                  $map_path[$id] = $#paths;
               }
            } elsif ($_[0] eq "o") {
               shift;
               my %o = @_;
               $in_o and $parser->xpcroak ("nested <o> detected");
               $in_o = 1;
               $o = { gid => $o{gid}, attr => {} };



( run in 0.616 second using v1.01-cache-2.11-cpan-39bf76dae61 )