Results 1 to 4 of 4

Thread: raw backup fails with dashes in database name

  1. #1

    Default raw backup fails with dashes in database name

    Hi,
    i have upgraded mysql from 5.0.x to 5.1.43 in debian.
    Since then, backups fail, because all "-" in databases names were replaced with @002d on disk - so db test-test in mysql is stored in /var/lib/mysql/test@002dtest
    Is that normal behaviour?
    I have made two (naive) patches, one for mysqlhotcopy and one for lvm-snapshot plugin (you need first to make raw backups and second just for backups using snapshot), just to have backups rolling again

    With regards
    Libor

    Code:
    --- mysqlhotcopy.orig   2010-02-01 23:50:00.000000000 +0100
    +++ mysqlhotcopy        2010-02-15 10:47:00.000000000 +0100
    @@ -285,7 +285,9 @@
         }
    
         ## get list of files to copy
    -    my $db_dir = "$datadir/$db";
    +    my $db_dir = "$db";
    +    $db_dir =~ s/-/\@002d/g;
    +    $db_dir = "$datadir/$db_dir";
         opendir(DBDIR, $db_dir )
           or die "Cannot open dir '$db_dir': $!";
    
    @@ -471,7 +473,9 @@
    
     foreach my $rdb ( @db_desc )
     {
    -  my @files = map { "$datadir/$rdb->{src}/$_" } @{$rdb->{files}};
    +  my $src = $rdb->{src};
    +  $src =~ s/-/\@002d/g;
    +  my @files = map { "$datadir/$src/$_" } @{$rdb->{files}};
       next unless @files;
    
       eval { copy_files($opt{method}, \@files, $rdb->{target}); };
    Code:
    --- lvm-snapshot.pl.orig        2010-01-08 22:59:05.000000000 +0100
    +++ lvm-snapshot.pl     2010-03-09 08:18:09.378310840 +0100
    @@ -46,7 +46,19 @@
            my $snapshotName = $_[1];
             my @ret = `sudo $DF '$_[0]'`;
             if( $? != 0 ) {
    -                &printAndDie( "Failed to find database: ".$_[0] );
    +               if ($_[0] =~ /-/)
    +               {
    +                       my $dir = $_[0];
    +                       $dir =~ s/-/\@002d/g;
    +                       @ret = `sudo $DF '$dir'`;
    +                       if( $? != 0 ) {
    +                               &printAndDie( "Failed to find database: ".$_[0] );
    +                       }
    +               }
    +               else
    +               {
    +                       &printAndDie( "Failed to find database: ".$_[0] );
    +               }
             }
            chomp( @ret );
             my @fs = split(" " , $ret[1]);

  2. #2

    Default

    Did the database names change after the MySQL upgrade to 5.1.43?

  3. #3

    Default

    Hi,
    yes, it happend during upgrade
    I was testing backups using zrm, so i noticed it
    One day, i fixed problem with openfileslimit, the other day, i upgraded mysql and backups were not working again ;)

  4. #4

    Default

    Hi, it seems, that dashes are ilegal characters in db and table names in 5.1
    This is message from ugprading another db
    mysqld: 100428 22:54:07 [ERROR] Invalid (old?) table or database name 'users-proma'

    So it's probably ok, i'll have to rename all db, tables

    Libor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •