source: xas-model/trunk/lib/XAS/Apps/Database/RemoveData.pm @ 5250ce3bd7dfd5e59c99936400210013b992b151

Revision 5250ce3bd7dfd5e59c99936400210013b992b151, 2.1 KB checked in by Kevin L. Esteb <kevin@…>, 6 years ago (diff)

Added procedures for manipulating Postgress database backup files

  • Property mode set to 100644
Line 
1package XAS::Apps::Database::RemoveData;
2
3our $VERSION = '0.02';
4
5use Try::Tiny;
6use XAS::Class
7  version   => $VERSION,
8  base      => 'XAS::Lib::App',
9  accessors => 'file',
10;
11
12# ----------------------------------------------------------------------
13# Public Methods
14# ----------------------------------------------------------------------
15
16sub parse_file {
17    my $self = shift;
18
19    my $fh;
20
21    open($fh, "<", $self->file);
22
23    LOOP:
24    while (<$fh>) {
25
26        if ($_ =~ m/^COPY \w+ \(/) {
27
28            while (<$fh>) {
29
30                next LOOP if ($_ =~ m/^\\\./);
31
32            }
33
34        }
35
36        print $_;
37
38    }
39
40}
41
42sub main {
43    my $self = shift;
44
45    $self->log->debug('starting main section');
46
47    $self->parse_file();
48
49    $self->log->debug('ending main section');
50
51}
52
53sub options {
54    my $self = shift;
55
56    $self->{file} = '';
57
58    return {
59        'file=s' => \$self->{file},
60    };
61
62}
63
64# ----------------------------------------------------------------------
65# Private Methods
66# ----------------------------------------------------------------------
67
681;
69
70__END__
71
72=head1 NAME
73
74XAS::Apps::Database::RemoveData - This module will remove data from a postgres dump file
75
76=head1 SYNOPSIS
77
78 use XAS::Apps::Database::RemoveData;
79
80 my $app = XAS::Database::Base::RemoveData->new(;
81    -throws  => 'xas-pg-remove-data',
82 );
83
84 exit $app->run();
85
86=head1 DESCRIPTION
87
88This module will strip the "copy" statements from a postgres pg_dumpall file.
89Thus producing a schema that is suitable to rebuild an "empty" database.
90It inherits from L<XAS::Lib::App>. Please see that module for additional
91documentation.
92
93=head1 OPTIONS
94
95This modules provides these additonal cli options.
96
97=head2 --file
98
99Defines the dump file to use.
100
101=head1 SEE ALSO
102
103=over 4
104
105=item bin/xas-pg-remove-data
106
107=item L<XAS|XAS>
108
109=back
110
111=head1 AUTHOR
112
113Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
114
115=head1 COPYRIGHT AND LICENSE
116
117Copyright (C) 2012 by Kevin L. Esteb
118
119This library is free software; you can redistribute it and/or modify
120it under the same terms as Perl itself, either Perl version 5.8.8 or,
121at your option, any later version of Perl 5 you may have available.
122
123=cut
Note: See TracBrowser for help on using the repository browser.