]> git.ipfire.org Git - thirdparty/bugzilla.git/blame - migrate.pl
add a new hook: template_after_create (#60)
[thirdparty/bugzilla.git] / migrate.pl
CommitLineData
9f3d18d4 1#!/usr/bin/perl
fe2a998b
FB
2# This Source Code Form is subject to the terms of the Mozilla Public
3# License, v. 2.0. If a copy of the MPL was not distributed with this
4# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4adf7f1b 5#
fe2a998b
FB
6# This Source Code Form is "Incompatible With Secondary Licenses", as
7# defined by the Mozilla Public License, v. 2.0.
4adf7f1b 8
1001cbba 9use 5.10.1;
4adf7f1b 10use strict;
9f3d18d4
FB
11use warnings;
12
4adf7f1b 13use File::Basename;
14BEGIN { chdir dirname($0); }
15use lib qw(. lib);
16use Bugzilla;
17use Bugzilla::Migrate;
18
19use Getopt::Long;
20use Pod::Usage;
21
22my %switch;
23GetOptions(\%switch, 'help|h|?', 'from=s', 'verbose|v+', 'dry-run');
24
25# Print the help message if that switch was selected or if --from
26# wasn't specified.
27if (!$switch{'from'} or $switch{'help'}) {
28 pod2usage({-exitval => 1});
29}
30
31my $migrator = Bugzilla::Migrate->load($switch{'from'});
32$migrator->verbose($switch{'verbose'});
33$migrator->dry_run($switch{'dry-run'});
34$migrator->check_requirements();
35$migrator->do_migration();
36
37# Even if there's an error, we want to be sure that the serial values
38# get reset properly.
39END {
40 if ($migrator and $migrator->dry_run) {
41 my $dbh = Bugzilla->dbh;
42 if ($dbh->bz_in_transaction) {
43 $dbh->bz_rollback_transaction();
44 }
45 $migrator->reset_serial_values();
46 }
47}
48
49__END__
50
51=head1 NAME
52
53migrate.pl - A script to migrate from other bug-trackers to Bugzilla.
54
55=head1 SYNOPSIS
56
57 ./migrate.pl --from=<tracker> [--verbose] [--dry-run]
58
59 Migrates from another bug-tracker to Bugzilla. If you want
60 to upgrade Bugzilla, use checksetup.pl instead.
61
62 Always test this on a backup copy of your database before
63 running it on your live Bugzilla.
64
65=head1 OPTIONS
66
67=over
68
69=item B<--from=tracker>
70
71Specifies what bug-tracker you're migrating from. To see what values
72are valid, see the contents of the F<Bugzilla/Migrate/> directory.
73
74=item B<--dry-run>
75
76Don't modify the Bugzilla database at all, just test the import.
77Note that this could cause significant slowdown and other strange effects
78on a live Bugzilla, so only use it on a test instance.
79
80=item B<--verbose>
81
82If specified, this script will output extra debugging information
83to STDERR. Specify multiple times (up to three) for more information.
84
85=back
86
87=head1 DESCRIPTION
88
89This script copies data from another bug-tracker into Bugzilla. It migrates
90users, products, and bugs from the other bug-tracker into this Bugzilla,
91without removing any of the data currently in this Bugzilla.
92
93Note that you will need enough space in your temporary directory to hold
94the size of all attachments in your current bug-tracker.
95
96You may also need to increase the number of file handles a process is allowed
97to hold open (as the migrator will create a file handle for each attachment
98in your database). On Linux and simliar systems, you can do this as root
fe2a998b 99by typing C<ulimit -n 65535> before running your script.