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 | |
---|
8 | use strict; |
---|
9 | use warnings; |
---|
10 | |
---|
11 | use FindBin; |
---|
12 | use lib "$FindBin::Bin/../lib"; |
---|
13 | use 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 | }; |
---|
20 | use FCM::Admin::Util qw{option2config}; |
---|
21 | use Getopt::Long qw{GetOptions}; |
---|
22 | use Pod::Usage qw{pod2usage}; |
---|
23 | |
---|
24 | main(); |
---|
25 | |
---|
26 | sub 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 | |
---|
62 | fcm-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 | |
---|
74 | Prints help and exits. |
---|
75 | |
---|
76 | =item --no-ini-file |
---|
77 | |
---|
78 | Do not backup the (central) INI file. This option is automatic if one or more |
---|
79 | project name is specified in the argument list. |
---|
80 | |
---|
81 | =item --no-passwd-file |
---|
82 | |
---|
83 | Do not backup the password file. This option is automatic if one or more project |
---|
84 | name is specified in the argument list. |
---|
85 | |
---|
86 | =item --no-verify-integrity |
---|
87 | |
---|
88 | If this option is specified, the program will not verify the integrity of the |
---|
89 | database before running the backup. |
---|
90 | |
---|
91 | =item --trac-backup-dir=DIR |
---|
92 | |
---|
93 | Specifies the root location of the backup directory. See |
---|
94 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
95 | |
---|
96 | =item --trac-ini-file=FILE |
---|
97 | |
---|
98 | Specifies the base name of the Trac INI file. See |
---|
99 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
100 | |
---|
101 | =item --trac-live-dir=DIR |
---|
102 | |
---|
103 | Specifies the root location of the live directory. See |
---|
104 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
105 | |
---|
106 | =item --trac-passwd-file=FILE |
---|
107 | |
---|
108 | Specifies the base name of the Trac password file. See |
---|
109 | L<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 | |
---|
119 | Specifies one or more project to back up. If no project is specified, the |
---|
120 | program searches the live directory for projects to back up. |
---|
121 | |
---|
122 | No attempt to backup the (central) INI file and the password file is made if one |
---|
123 | or more project name is specified. |
---|
124 | |
---|
125 | =back |
---|
126 | |
---|
127 | =head1 DESCRIPTION |
---|
128 | |
---|
129 | This program archives Trac environments, the (central) INI file and the password |
---|
130 | file in the live directory to the backup directory. |
---|
131 | |
---|
132 | =head1 COPYRIGHT |
---|
133 | |
---|
134 | E<169> Crown copyright Met Office. All rights reserved. |
---|
135 | |
---|
136 | =cut |
---|