diff options
Diffstat (limited to 'scripts/mysqlhotcopy.sh')
-rw-r--r-- | scripts/mysqlhotcopy.sh | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index 5977a181c93..48aefbd8c49 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -73,6 +73,8 @@ Usage: $0 db_name[./table_regex/] [new_db_name | directory] -h, --host=# hostname for local server when connecting over TCP/IP -P, --port=# port to use when connecting to local server with TCP/IP -S, --socket=# socket to use when connecting to local server + --old_server connect to old MySQL-server (before v5.5) which + doesn't have FLUSH TABLES WITH READ LOCK fully implemented. --allowold don\'t abort if target dir already exists (rename it _old) --addtodest don\'t rename target dir if it exists, just add files to it @@ -120,6 +122,7 @@ GetOptions( \%opt, "password|p=s", "port|P=s", "socket|S=s", + "old_server", "allowold!", "keepold!", "addtodest!", @@ -248,10 +251,6 @@ elsif (defined($tgt_name) && ($tgt_name =~ m:/: || $tgt_name eq '.')) { elsif ( $opt{suffix} ) { print "Using copy suffix '$opt{suffix}'\n" unless $opt{quiet}; } -elsif ( ($^O =~ m/^(NetWare)$/) && defined($tgt_name) && ($tgt_name =~ m:\\: || $tgt_name eq '.')) -{ - $tgt_dirname = $tgt_name; -} else { $tgt_name="" if (!defined($tgt_name)); @@ -437,11 +436,8 @@ foreach my $rdb ( @db_desc ) { else { mkdir($tgt_dirpath, 0750) or die "Can't create '$tgt_dirpath': $!\n" unless -d $tgt_dirpath; - if ($^O !~ m/^(NetWare)$/) - { - my @f_info= stat "$datadir/$rdb->{src}"; - chown $f_info[4], $f_info[5], $tgt_dirpath; - } + my @f_info= stat "$datadir/$rdb->{src}"; + chown $f_info[4], $f_info[5], $tgt_dirpath; } } @@ -466,21 +462,37 @@ if ( $opt{checkpoint} || $opt{record_log_pos} ) { my $hc_started = time; # count from time lock is granted if ( $opt{dryrun} ) { - print "LOCK TABLES $hc_locks\n"; - print "FLUSH TABLES /*!32323 $hc_tables */\n"; + if ( $opt{old_server} ) { + print "LOCK TABLES $hc_locks\n"; + print "FLUSH TABLES /*!32323 $hc_tables */\n"; + } + else { + print "FLUSH TABLES $hc_tables WITH READ LOCK\n"; + } + print "FLUSH LOGS\n" if ( $opt{flushlog} ); print "RESET MASTER\n" if ( $opt{resetmaster} ); print "RESET SLAVE\n" if ( $opt{resetslave} ); } else { my $start = time; - $dbh->do("LOCK TABLES $hc_locks"); - printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet}; - $hc_started = time; # count from time lock is granted + if ( $opt{old_server} ) { + $dbh->do("LOCK TABLES $hc_locks"); + printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet}; + $hc_started = time; # count from time lock is granted + + # flush tables to make on-disk copy up to date + $start = time; + $dbh->do("FLUSH TABLES /*!32323 $hc_tables */"); + } + else { + $dbh->do("FLUSH TABLES $hc_tables WITH READ LOCK"); + printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet}; + $hc_started = time; # count from time lock is granted - # flush tables to make on-disk copy up to date - $start = time; - $dbh->do("FLUSH TABLES /*!32323 $hc_tables */"); + # flush tables to make on-disk copy up to date + $start = time; + } printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet}; $dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} ); $dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} ); @@ -596,14 +608,7 @@ sub copy_files { my @cmd; print "Copying ".@$files." files...\n" unless $opt{quiet}; - if ($^O =~ m/^(NetWare)$/) # on NetWare call PERL copy (slower) - { - foreach my $file ( @$files ) - { - copy($file, $target."/".basename($file)); - } - } - elsif ($method =~ /^s?cp\b/) # cp or scp with optional flags + if ($method =~ /^s?cp\b/) # cp or scp with optional flags { my $cp = $method; # add option to preserve mod time etc of copied files @@ -1000,6 +1005,10 @@ when using the --host option. UNIX domain socket to use when connecting to local server. +=item --old_server + +Use old server (pre v5.5) commands. + =item --noindices Don\'t include index files in copy. Only up to the first 2048 bytes |