source: XIOS/tools/FCM/examples/sbin/fcm-backup-trac-env @ 1293

Last change on this file since 1293 was 81, checked in by ymipsl, 12 years ago

ajout FCM 1.5

File size: 3.2 KB
Line 
1#!/usr/bin/perl
2# ------------------------------------------------------------------------------
3# (C) Crown copyright Met Office. All rights reserved.
4# For further details please refer to the file COPYRIGHT.txt
5# which you should have received as part of this distribution.
6# ------------------------------------------------------------------------------
7
8use strict;
9use warnings;
10
11use FindBin;
12use lib "$FindBin::Bin/../lib";
13use FCM::Admin::System qw{
14    backup_trac_environment
15    backup_trac_ini_file
16    backup_trac_passwd_file
17    filter_projects
18    get_projects_from_trac_live
19};
20use FCM::Admin::Util qw{option2config};
21use Getopt::Long qw{GetOptions};
22use Pod::Usage qw{pod2usage};
23
24main();
25
26sub main {
27    my %option;
28    my $result = GetOptions(
29        \%option,
30        q{help|usage|h},
31        q{no-ini-file},
32        q{no-passwd-file},
33        q{no-verify-integrity},
34        q{trac-backup-dir=s},
35        q{trac-ini-file=s},
36        q{trac-live-dir=s},
37        q{trac-passwd-file=s},
38    );
39    if (!$result) {
40        pod2usage(1);
41    }
42    if (exists($option{help})) {
43        pod2usage(q{-verbose} => 1);
44    }
45    option2config(\%option);
46    my @projects = filter_projects([get_projects_from_trac_live()], \@ARGV);
47    for my $project (@projects) {
48        backup_trac_environment($project, !$option{q{no-verify-integrity}});
49    }
50    if (!@ARGV && !exists($option{q{no-ini-file}})) {
51        backup_trac_ini_file();
52    }
53    if (!@ARGV && !exists($option{q{no-passwd-file}})) {
54        backup_trac_passwd_file();
55    }
56}
57
58__END__
59
60=head1 NAME
61
62fcm-backup-trac-env
63
64=head1 SYNOPSIS
65
66    fcm-backup-trac-env [OPTIONS] [PROJECT ...]
67
68=head1 OPTIONS
69
70=over 4
71
72=item --help, -h, --usage
73
74Prints help and exits.
75
76=item --no-ini-file
77
78Do not backup the (central) INI file. This option is automatic if one or more
79project name is specified in the argument list.
80
81=item --no-passwd-file
82
83Do not backup the password file. This option is automatic if one or more project
84name is specified in the argument list.
85
86=item --no-verify-integrity
87
88If this option is specified, the program will not verify the integrity of the
89database before running the backup.
90
91=item --trac-backup-dir=DIR
92
93Specifies the root location of the backup directory. See
94L<FCM::Admin::Config|FCM::Admin::Config> for the current default.
95
96=item --trac-ini-file=FILE
97
98Specifies the base name of the Trac INI file. See
99L<FCM::Admin::Config|FCM::Admin::Config> for the current default.
100
101=item --trac-live-dir=DIR
102
103Specifies the root location of the live directory. See
104L<FCM::Admin::Config|FCM::Admin::Config> for the current default.
105
106=item --trac-passwd-file=FILE
107
108Specifies the base name of the Trac password file. See
109L<FCM::Admin::Config|FCM::Admin::Config> for the current default.
110
111=back
112
113=head1 ARGUMENTS
114
115=over 4
116
117=item PROJECT
118
119Specifies one or more project to back up. If no project is specified, the
120program searches the live directory for projects to back up.
121
122No attempt to backup the (central) INI file and the password file is made if one
123or more project name is specified.
124
125=back
126
127=head1 DESCRIPTION
128
129This program archives Trac environments, the (central) INI file and the password
130file in the live directory to the backup directory.
131
132=head1 COPYRIGHT
133
134E<169> Crown copyright Met Office. All rights reserved.
135
136=cut
Note: See TracBrowser for help on using the repository browser.