source: MondoRescue/branches/3.3/MondoRescue/bin/mr-analyze-lvm@ 3650

Last change on this file since 3650 was 3650, checked in by Bruno Cornec, 7 years ago
  • Fix versions given back for mr-* tools
  • Log pb and mr versions in mindi log
  • mr-getparam now prints a version
  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#!/usr/bin/perl -w
2#
3# Analyze the LVM configuration
4# and store the configuration for restore time
5#
6# $Id$
7#
8# Copyright B. Cornec 2008-2014
9# Provided under the GPL v2
10
11# Syntax: see below
12
13use strict 'vars';
14use Getopt::Long qw(:config auto_abbrev no_ignore_case);
15use Data::Dumper;
16use English;
17use lib qw (lib);
18use ProjectBuilder::Base;
19use ProjectBuilder::Distribution;
20use MondoRescue::Version;
21use MondoRescue::Base;
22use MondoRescue::LVM;
23
24=pod
25
26=head1 NAME
27
28mr-analyze-lvm - A MondoRescue Tool to analyze the LVM configuration and store it
29
30=head1 DESCRIPTION
31
32B<mr-analyze-lvm> prints all the information related to the LVM configuration that may be used by a restoration process
33
34=head1 SYNOPSIS
35
36mr-analyze-lvm [-v]|[-q]|[-h]|[--man][-o outputfile][-l logfile]
37
38=head1 OPTIONS
39
40=over 4
41
42=item B<-v|--verbose>
43
44Be more verbose
45
46=item B<-q|--quiet>
47
48Do not print any output.
49
50=item B<-h|--help>
51
52Print a brief help message and exits.
53
54=item B<--man>
55
56Prints the manual page and exits.
57
58=item B<-o|--output>
59
60Name of the file to generate. Use stdout by default
61
62The output format is:
63LVM:lvm-version
64PV:pv-information as done with pvdisplay -c
65VG:vg-information as done with vgdisplay -c
66LV:lv-information as done with lvdisplay -c
67
68=back
69
70=head1 WEB SITES
71
72The main Web site of the project is available at L<http://www.mondorescue.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>.
73
74=head1 USER MAILING LIST
75
76The mailing list of the project is available at L<mailto:mondo@lists.sf.net>
77
78=head1 AUTHORS
79
80The Mondorescue.org team L<http://www.mondorescue.org/> lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
81
82=head1 COPYRIGHT
83
84Analyze-LVM is distributed under the GPL v2.0 license
85described in the file C<COPYING> included with the distribution.
86
87=cut
88
89
90# ---------------------------------------------------------------------------
91# Globals
92my %opts; # CLI Options
93
94# Initialize the syntax string
95
96pb_syntax_init("mr-analyze-lvm Version PBVER-rPBREV\n");
97
98# Handle options
99#
100GetOptions("help|?|h" => \$opts{'h'},
101 "man" => \$opts{'man'},
102 "verbose|v+" => \$opts{'v'},
103 "quiet|q" => \$opts{'q'},
104 "output|o=s" => \$opts{'o'},
105 "log-files|l=s" => \$opts{'l'},
106 "version|V" => \$opts{'V'},
107) || pb_syntax(-1,0);
108
109# easy options
110if (defined $opts{'h'}) {
111 pb_syntax(0,1);
112}
113if (defined $opts{'man'}) {
114 pb_syntax(0,2);
115}
116if (defined $opts{'v'}) {
117 $pbdebug = $opts{'v'};
118}
119if (defined $opts{'q'}) {
120 $pbdebug=-1;
121}
122
123#
124# Global variables
125#
126my $MRMINI_VERSION = "PBVER-rPBREV";
127my $MRMINI_PREFIX = "PBPREFIX";
128my $MRMINI_CONF = "PBCONF";
129my $MRMINI_BIN = "$MRMINI_PREFIX/bin";
130my $MRMINI_LIB = "$MRMINI_PREFIX/lib";
131
132# Init
133mr_init();
134
135# -------------------------------- main -----------------------------------
136# Where to send the output
137my $OUTPUT = \*STDOUT;
138if (defined $opts{'o'}) {
139 open(OUTPUT, "> $opts{'o'}") || mr_exit(-1, "Unable to write to $opts{'o'}");
140 $OUTPUT = \*OUTPUT;
141}
142
143my $lvm = mr_lvm_analyze($OUTPUT);
144
145if (not defined $lvm) {
146 pb_log(1,"No LVM handling\n") ;
147} else {
148 pb_log(1,"LVM Structure :".Dumper($lvm)."\n");
149}
150
151open(LVM, "> /tmp/lvm.out") || mr_exit(-1, "Unable to write to /tmp/lvm.out");
152$lvm = mr_lvm_analyze(\*LVM);
153close(LVM);
154open(LVM, "/tmp/lvm.out") || mr_exit(-1, "Unable to read to /tmp/lvm.out");
155$lvm = mr_lvm_prepare(\*LVM,$OUTPUT,1);
156close(LVM);
157
158if (defined $opts{'o'}) {
159 close($OUTPUT);
160}
161mr_exit(0,undef);
Note: See TracBrowser for help on using the repository browser.