#!/usr/bin/perl # # Copyright (c) 2006 Zmanda Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120 # Sunnyvale, CA 94085, USA, or: http://www.zmanda.com # # use strict; use warnings; use Getopt::Long; use File::Copy; use File::Find; use File::Path; use File::Spec::Functions; use File::Basename; use POSIX qw(strftime); use Fcntl ':flock'; use File::Temp qw/ :POSIX /; use lib "/usr/lib/mysql-zrm"; use ZRM::Common; use ZRM::MySQL; use File::Spec::Functions; $SIG{'TERM'} = sub { $abort_flag = 1; }; $SIG{'PIPE'} = sub { &printWarning( "Communication pipe broke. Continuing\n" ); }; my $MD5SUM="md5sum"; my $MAILCMD=""; if ($^O =~ /^solaris/) { $MAILCMD="/usr/ucb/mail"; } else { $MAILCMD="mail"; } #Neither mysqlhotcopy not mysqldump will do a --flush-logs #so as to avoid flushing multiple times. #Instead flush logs wil lbe called explicitly before data is backed up my $MYSQLDUMP5="mysqldump --opt --extended-insert --create-options"; my $MYSQLDUMP41="mysqldump --opt --extended-insert"; # Lock tables and default-character-set are not compatible in mysqldump 4.0 my $MYSQLDUMP40="mysqldump --opt --extended-insert --all"; my %SUPPORTED_NONTRANS_ENGINES = ( MyISAM => "1" , MRG_MyISAM => "1", MERGE => "1", FEDERATED => "1", CSV => "1", NULL => "1", ARCHIVE => "1" ); my %SUPPORTED_IHB_ENGINES = ( MyISAM => "1" , MRG_MyISAM => "1", MERGE => "1", FEDERATED => "1", InnoDB => "1" ); #Setup defaults my $pid_file = 0; my $flushLogsTime=0; my $readLocksTime=0; my @dirList; my %checkForDir; my %lvmInnoDBDirTable; my %lvmDirTable; my %snapshotDirMap; my %snapshotNameMap; my %fsTypeMap; my %devMountPnt; my %relativeCopyDir; my %mountTable; my %mountFSType; my $linksToBeCreated = 1; my %mdcheck; my $nextBinLog; my $index_open = 0; my $logicalCet = 0; my $linkFile = ""; my $isReplicating = 0; my $USAGE_BACKUP_STRING= "\t\t[--user\ ]\ [--password\ ]\n". "\t\t[--host\ ]\ [--port\ ]\n". "\t\t[--socket\ ]\ [--ssl-options\ <\"MySQL\ ssl\ options\">]\n". "\t\t[--mysql-binpath\ ]\n". "\t\t[--mysql-binlog-path ]\n". "\t\t[--backup-name ]\n". "\t\t[--mailto ]\n". "\t\t[--mail-policy ]\n". "\t\t[--comment \"This is a comment\"]\n". "\t\t[--all-databases]\ [--databases\ <\"name1\ name2\ ...\">]\n". "\t\t[--database [--tables <\"name1 name2 ...\">]]\n". "\t\t[--exclude-pattern ]\n". "\t\t[--backup-level <0|1>]\n". "\t\t[--backup-mode ]\n". "\t\t[--destination\ ]\n". "\t\t[--lvm-snapshot (This option is deprecated. Use snapshot-size)]\n". "\t\t[--snapshot-size ]\n". "\t\t[--snapshot-plugin ]\n". "\t\t[--backup-type ]\n". "\t\t[--replication\ |\ --noreplication]\n". "\t\t[--default-character-set ]\n". "\t\t[--compress|--no-compress]\n". "\t\t[--compress-mysqldump-onthefly|--no-compress-mysqldump-onthefly]\n". "\t\t[--compress-plugin ]\n". "\t\t[--encrypt|--no-encrypt]\n". "\t\t[--encrypt-plugin [--decrypt-option