MigrateBugzillaToRT

From Request Tracker Wiki
Jump to: navigation, search

************************** * Bugzilla RT migration * Javier Garcia * Snow Valley * javier(dot)garcia(at)snowvalley(dot)com * 24/04/2009 <hr /> Environment: - OS: Debian Etch 2.6.18-6-486 - RT version: 3.8.2 - MySQL version: 5.0.32-Debian_7etch8-log I. Download and untar migration files <hr /> tar -xvzf bugzilla-rt-convert.tar.gz II. Read README file <hr /> Please, pay attention to the README file inside bugzilla-rt-convert folder III. Replace initial data file <hr /> The original /opt/rt3/etc/initialdata file on RT3.8 has no groups information. We have to insert this information in our DB in order to avoid future issues loading tickets and queues. @Groups = ( { Name => '', Type => 'Everyone', Domain => 'SystemInternal', Instance => '', Description => 'Pseudogroup for internal use', InsideTransaction => undef, }, { Type => 'Privileged', Domain => 'SystemInternal', Instance => '', Name => '', Description => 'Pseudogroup for internal use', InsideTransaction => undef, }, { Name => '', Type => 'Unprivileged', Domain => 'SystemInternal', Instance => '', Description => 'Pseudogroup for internal use', InsideTransaction => undef, }, { Name => '', Type => 'Owner', Domain => 'RT::System-Role', Instance => '', Description => 'SystemRolegroup for internal use', InsideTransaction => undef, }, { Name => '', Type => 'Requestor', Domain => 'RT::System-Role', Instance => '', Description => 'SystemRolegroup for internal use', InsideTransaction => undef, }, { Name => '', Type => 'Cc', Domain => 'RT::System-Role', Instance => '', Description => 'SystemRolegroup for internal use', InsideTransaction => undef, }, { Name => '', Type => 'AdminCc', Domain => 'RT::System-Role', Instance => '', Description => 'Pseudogroup for internal use', InsideTransaction => undef, }, ); IV. print_prod.pl <hr /> This script loads tickets information from bugzilla in a file. There are issues in some of the loaded data, as lots of creation date fields contain the string ‘now()’ instead of a valid date. The best way to fix this is to replace the following lines in the script: ### sub print_prod my $created = 'now()'; ... print "\t Description\t=> $desc,\n"; print "\t Created\t=> $created,\n"; With these ones (NOTE: we are adding a random created date. Some people will need to modify this as they have to use the current date and time. Perl provides lots of time functions for this): ### sub print_prod my $created = 'now()'; ... print "\t Description\t=> $desc,\n"; # ### ADDED TO AVOID now() DATES WHICH CAUSE LOADING ERRORS ON RT if ($created eq 'now()') { print "\t Created\t=> '2009-04-22 11:00:00',\n"; }else { print "\t Created\t=> $created,\n"; } V. print_bugs.pl <hr /> This script loads bugs information from bugzilla in a file. We are in the same situation again, as there a lots of corrupted data. The best way to fix this is to replace the following lines in the script: ### sub print_bugs my $created = 'now()'; ... print "\t Type\t=> 'ticket',\n"; print "\t Created\t=> $created,\n"; With these ones (NOTE: we are adding a random created date. Some people will need to modify this as they have to use the current date and time. Perl provides lots of time functions for this): ### sub print_bugs my $created = 'now()'; ... print "\t Type\t=> 'ticket',\n"; # ### ADDED TO AVOID now() DATES WHICH CAUSE LOADING ERRORS ON RT if ($created eq 'now()') { print "\t Created\t=> '2009-04-22 11:00:00',\n"; }else { print "\t Created\t=> $created,\n"; } VI. migrate.sh <hr /> Modify create_user function adding a line for the DB initialization. This initialization is needed as ‘Nobody’ and ‘System’ users are not automatically added by the original script. create_user(){ passwd=$1 perl $setup --action drop --dba root --dba-password $passwd # We have to initialize the DB, as we need to insert Nobody and # System users, which are required and the original script doesn't # carry this out perl $setup --action init --dba root --dba-password $passwd <code><pre> # don't insert scrip here perl bugimport --action init --dba root --dba-password $passwd perl print_users_groups.pl $passwd &gt; data.pl perl $setup --action insert --datafile ./data.pl --dba root --dba-password $passwd perl insert_ids_map.pl $passwd </pre></code> } VII. Stop emailing <hr /> In order to avoid thousands of emails to be sent automatically, every time a new ticket is created, we have to stop our mail client VIII. Run migration script <hr /> The best way to run the script is redirecting the standard error (which contains also Perl warning and informational messages) to a file sh migrate.sh 2> output IX. Delete queued emails <hr /> Before restarting the email client we have to delete all the queued emails: rm -f /var/spool/mqueue/* /var/spool/mqueue-client/* NOTE: If there are too much pending emails, rm won’t work and you will need to use the following command instead: cd /var/spool/mqueue find . -name '<em>' -print0 | xargs -0 rm cd /var/spool/mqueue-client find . -name '</em>' -print0 | xargs -0 rm X. Restart email client <hr />