[5129] | 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 | backup_trac_environment |
---|
| 28 | backup_trac_files |
---|
| 29 | filter_projects |
---|
| 30 | get_projects_from_trac_live |
---|
| 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{no-verify-integrity}, |
---|
| 44 | q{trac-backup-dir=s}, |
---|
| 45 | q{trac-live-dir=s}, |
---|
| 46 | ); |
---|
| 47 | if (!$result) { |
---|
| 48 | pod2usage(1); |
---|
| 49 | } |
---|
| 50 | if (exists($option{help})) { |
---|
| 51 | pod2usage(q{-verbose} => 1); |
---|
| 52 | } |
---|
| 53 | option2config(\%option); |
---|
| 54 | my @projects = filter_projects([get_projects_from_trac_live()], \@ARGV); |
---|
| 55 | for my $project (@projects) { |
---|
| 56 | backup_trac_environment(\%option, $project); |
---|
| 57 | } |
---|
| 58 | if (!@ARGV) { |
---|
| 59 | backup_trac_files(); |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | __END__ |
---|
| 64 | |
---|
| 65 | =head1 NAME |
---|
| 66 | |
---|
| 67 | fcm-backup-trac-env |
---|
| 68 | |
---|
| 69 | =head1 SYNOPSIS |
---|
| 70 | |
---|
| 71 | fcm-backup-trac-env [OPTIONS] [PROJECT ...] |
---|
| 72 | |
---|
| 73 | =head1 OPTIONS |
---|
| 74 | |
---|
| 75 | =over 4 |
---|
| 76 | |
---|
| 77 | =item --help, -h, --usage |
---|
| 78 | |
---|
| 79 | Prints help and exits. |
---|
| 80 | |
---|
| 81 | =item --no-verify-integrity |
---|
| 82 | |
---|
| 83 | If this option is specified, the program will not verify the integrity of the |
---|
| 84 | database before running the backup. |
---|
| 85 | |
---|
| 86 | =item --trac-backup-dir=DIR |
---|
| 87 | |
---|
| 88 | Specifies the root location of the backup directory. See |
---|
| 89 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
| 90 | |
---|
| 91 | =item --trac-live-dir=DIR |
---|
| 92 | |
---|
| 93 | Specifies the root location of the live directory. See |
---|
| 94 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
| 95 | |
---|
| 96 | =back |
---|
| 97 | |
---|
| 98 | =head1 ARGUMENTS |
---|
| 99 | |
---|
| 100 | =over 4 |
---|
| 101 | |
---|
| 102 | =item PROJECT |
---|
| 103 | |
---|
| 104 | Specifies one or more project to back up. If no project is specified, the |
---|
| 105 | program searches the live directory for projects and other files to back up. |
---|
| 106 | |
---|
| 107 | =back |
---|
| 108 | |
---|
| 109 | =head1 DESCRIPTION |
---|
| 110 | |
---|
| 111 | This program archives Trac environments, and other files in the live directory |
---|
| 112 | to the backup directory. |
---|
| 113 | |
---|
| 114 | =head1 COPYRIGHT |
---|
| 115 | |
---|
| 116 | Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
---|
| 117 | |
---|
| 118 | =cut |
---|