| 1 | #!/usr/bin/perl |
|---|
| 2 | #------------------------------------------------------------------------------- |
|---|
| 3 | # Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
|---|
| 4 | # |
|---|
| 5 | # This file is part of FCM, tools for managing and building source code. |
|---|
| 6 | # |
|---|
| 7 | # FCM is free software: you can redistribute it and/or modify |
|---|
| 8 | # it under the terms of the GNU General Public License as published by |
|---|
| 9 | # the Free Software Foundation, either version 3 of the License, or |
|---|
| 10 | # (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # FCM is distributed in the hope that it will be useful, |
|---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | # GNU General Public License for more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License |
|---|
| 18 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 19 | #------------------------------------------------------------------------------- |
|---|
| 20 | |
|---|
| 21 | use strict; |
|---|
| 22 | use warnings; |
|---|
| 23 | |
|---|
| 24 | use FindBin; |
|---|
| 25 | use lib "$FindBin::Bin/../lib"; |
|---|
| 26 | use FCM::Admin::System qw{ |
|---|
| 27 | filter_projects |
|---|
| 28 | get_projects_from_trac_backup |
|---|
| 29 | recover_trac_environment |
|---|
| 30 | recover_trac_files |
|---|
| 31 | }; |
|---|
| 32 | use FCM::Admin::Util qw{option2config}; |
|---|
| 33 | use Getopt::Long qw{GetOptions}; |
|---|
| 34 | use Pod::Usage qw{pod2usage}; |
|---|
| 35 | |
|---|
| 36 | main(); |
|---|
| 37 | |
|---|
| 38 | sub main { |
|---|
| 39 | my %option; |
|---|
| 40 | my $result = GetOptions( |
|---|
| 41 | \%option, |
|---|
| 42 | q{help|usage|h}, |
|---|
| 43 | q{trac-backup-dir=s}, |
|---|
| 44 | q{trac-live-dir=s}, |
|---|
| 45 | ); |
|---|
| 46 | if (!$result) { |
|---|
| 47 | pod2usage(1); |
|---|
| 48 | } |
|---|
| 49 | if (exists($option{help})) { |
|---|
| 50 | pod2usage(q{-verbose} => 1); |
|---|
| 51 | } |
|---|
| 52 | option2config(\%option); |
|---|
| 53 | my @projects = filter_projects([get_projects_from_trac_backup()], \@ARGV); |
|---|
| 54 | for my $project (@projects) { |
|---|
| 55 | recover_trac_environment($project); |
|---|
| 56 | } |
|---|
| 57 | if (!@ARGV) { |
|---|
| 58 | recover_trac_files(); |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | __END__ |
|---|
| 63 | |
|---|
| 64 | =head1 NAME |
|---|
| 65 | |
|---|
| 66 | fcm-recover-trac-env |
|---|
| 67 | |
|---|
| 68 | =head1 SYNOPSIS |
|---|
| 69 | |
|---|
| 70 | fcm-recover-trac-env [OPTIONS] [PROJECT ...] |
|---|
| 71 | |
|---|
| 72 | =head1 OPTIONS |
|---|
| 73 | |
|---|
| 74 | =over 4 |
|---|
| 75 | |
|---|
| 76 | =item --help, -h, --usage |
|---|
| 77 | |
|---|
| 78 | Prints help and exits. |
|---|
| 79 | |
|---|
| 80 | =item --trac-backup-dir=DIR |
|---|
| 81 | |
|---|
| 82 | Specifies the root location of the backup directory. See |
|---|
| 83 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
|---|
| 84 | |
|---|
| 85 | =item --trac-live-dir=DIR |
|---|
| 86 | |
|---|
| 87 | Specifies the root location of the live directory. See |
|---|
| 88 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
|---|
| 89 | |
|---|
| 90 | =back |
|---|
| 91 | |
|---|
| 92 | =head1 ARGUMENTS |
|---|
| 93 | |
|---|
| 94 | =over 4 |
|---|
| 95 | |
|---|
| 96 | =item PROJECT |
|---|
| 97 | |
|---|
| 98 | Specifies one or more project to recover. If no project is specified, the |
|---|
| 99 | program searches the backup directory for projects and files to recover. |
|---|
| 100 | |
|---|
| 101 | =back |
|---|
| 102 | |
|---|
| 103 | =head1 DESCRIPTION |
|---|
| 104 | |
|---|
| 105 | This program recovers Trac environments and files from the backup directory to |
|---|
| 106 | the live directory. |
|---|
| 107 | |
|---|
| 108 | =head1 COPYRIGHT |
|---|
| 109 | |
|---|
| 110 | Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
|---|
| 111 | |
|---|
| 112 | =cut |
|---|