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