]>
Commit | Line | Data |
---|---|---|
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 | 9 | use 5.10.1; |
4adf7f1b | 10 | use strict; |
9f3d18d4 FB |
11 | use warnings; |
12 | ||
4adf7f1b | 13 | use File::Basename; |
14 | BEGIN { chdir dirname($0); } | |
15 | use lib qw(. lib); | |
16 | use Bugzilla; | |
17 | use Bugzilla::Migrate; | |
18 | ||
19 | use Getopt::Long; | |
20 | use Pod::Usage; | |
21 | ||
22 | my %switch; | |
23 | GetOptions(\%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. | |
27 | if (!$switch{'from'} or $switch{'help'}) { | |
28 | pod2usage({-exitval => 1}); | |
29 | } | |
30 | ||
31 | my $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. | |
39 | END { | |
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 | ||
53 | migrate.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 | ||
71 | Specifies what bug-tracker you're migrating from. To see what values | |
72 | are valid, see the contents of the F<Bugzilla/Migrate/> directory. | |
73 | ||
74 | =item B<--dry-run> | |
75 | ||
76 | Don't modify the Bugzilla database at all, just test the import. | |
77 | Note that this could cause significant slowdown and other strange effects | |
78 | on a live Bugzilla, so only use it on a test instance. | |
79 | ||
80 | =item B<--verbose> | |
81 | ||
82 | If specified, this script will output extra debugging information | |
83 | to STDERR. Specify multiple times (up to three) for more information. | |
84 | ||
85 | =back | |
86 | ||
87 | =head1 DESCRIPTION | |
88 | ||
89 | This script copies data from another bug-tracker into Bugzilla. It migrates | |
90 | users, products, and bugs from the other bug-tracker into this Bugzilla, | |
91 | without removing any of the data currently in this Bugzilla. | |
92 | ||
93 | Note that you will need enough space in your temporary directory to hold | |
94 | the size of all attachments in your current bug-tracker. | |
95 | ||
96 | You may also need to increase the number of file handles a process is allowed | |
97 | to hold open (as the migrator will create a file handle for each attachment | |
98 | in your database). On Linux and simliar systems, you can do this as root | |
fe2a998b | 99 | by typing C<ulimit -n 65535> before running your script. |