Re: Migrating Bugzilla between different time zones - problem
glauber ribeiro <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.webtools |
|---|---|
| Message-ID | <[email protected]> |
At this point, since i'm not convinced i want to take the additional risk of a MySQL to PostgreSQL migration, the state of this madness is i wrote a quick Perl script to translate each timestamp from local time (Chicago) to UTC, as it's being dumped. It seems to have worked...
Now to do some QA.
Here's the perl script - it's very naive, because (why not) i'm also rather limited in the number of modules i have available. I called it tconvert.pl.
#!/usr/bin/perl -w
use POSIX;
use Time::Local;
sub conv {
($Y,$M,$D,$h,$m,$s) = @_;
$time = timelocal($s,$m,$h,$D,$M - 1,$Y);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($time);
$mon++;
$year += 1900;
my $gmt_ts = sprintf("'%04d-%02d-%02d %02d:%02d:%02d'",
$year, $mon, $mday, $hour, $min, $sec);
# print STDERR "$Y-$M-$D $h:$m:$s -> $gmt_ts\n";
return $gmt_ts;
}
while (<STDIN>) {
$_ =~ s/'(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})'/conv($1,$2,$3,$4,$5,$6)/ge;
print;
}
I put this in line, like this (simplified)
mysqldump [options] | tconvert.pl | bzip2 >dumpfile.sql.bz2
g
_______________________________________________
support-bugzilla mailing list
[email protected]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [email protected] in the To: field when you reply.