75
75
my $option_throttle = '';
76
76
my $option_sleep = '';
77
77
my $option_compress = 999;
78
my $option_compress_threads = 1;
78
79
my $option_uncompress = '';
79
80
my $option_export = '';
80
81
my $option_use_memory = '';
456
458
system("scp $option_scp_opt '$option_tmpdir/xtrabackup_checkpoints' '$option_remote_host:$backup_dir/xtrabackup_checkpoints'")
457
459
and Die "Failed to scp file '$option_remote_host:$backup_dir/xtrabackup_checkpoints': $!";
458
460
unlink "$option_tmpdir/xtrabackup_checkpoints" || Die "Failed to delete '$option_tmpdir/xtrabackup_checkpoints': $!";
459
} elsif ($option_stream eq 'tar') {
460
system("cd $option_tmpdir; tar chf - xtrabackup_logfile")
461
and Die "Failed to stream 'xtrabackup_logfile': $!";
462
unlink $tmp_logfile || Die "Failed to delete '$tmp_logfile': $!";
464
system("cd $option_tmpdir; tar chf - xtrabackup_checkpoints")
465
and Die "Failed to stream 'xtrabackup_checkpoints': $!";
466
unlink "$option_tmpdir/xtrabackup_checkpoints" || Die "Failed to delete '$option_tmpdir/xtrabackup_checkpoints': $!";
469
463
print STDERR "\n$prefix Backup created in directory '$backup_dir'\n";
874
868
$options = $options . " --target-dir=$backup_dir";
876
870
#(datadir) for 'xtrabackup_suspended' and 'xtrabackup_checkpoints'
877
$options = $options . " --log-stream --target-dir=" . $option_tmpdir;
871
$options = $options . " --target-dir=" . $option_tmpdir;
872
if ($option_remote_host) {
873
$options = $options . " --log-stream";
880
877
# prepare command line for running ibbackup
885
882
$options = $options . " --sleep=$option_sleep";
887
884
if ($option_compress) {
888
$options = $options . " --compress=$option_compress";
885
$options = $options . " --compress";
886
$options = $options . " --compress-threads=$option_compress_threads";
890
888
if ($option_use_memory) {
891
889
$options = $options . " --use-memory=$option_use_memory";
909
907
$options = $options . " --tables_file='$option_tables_file'";
911
909
if ($option_parallel) {
912
$options = $options. " --parallel=$option_parallel";
910
$options = $options . " --parallel=$option_parallel";
912
if ($option_stream) {
913
$options = $options . " --stream=$option_stream";
914
915
$cmdline = "$option_ibbackup_binary $options";
939
if($option_remote_host) {
940
if (system("ssh $option_ssh_opt $option_remote_host test -e $backup_dir/ib_logfile0")
942
print STDERR "$prefix Remove $option_remote_host:$backup_dir/ib_logfile*\n";
943
system("ssh $option_ssh_opt $option_remote_host rm $backup_dir/ib_logfile\*")
944
and Die "Failed to rm file '$backup_dir/ib_logfile*': $!";
940
if (system("ssh $option_ssh_opt $option_remote_host test -e $backup_dir/ib_logfile0")
942
print STDERR "$prefix Remove $option_remote_host:$backup_dir/ib_logfile*\n";
943
system("ssh $option_ssh_opt $option_remote_host rm $backup_dir/ib_logfile\*")
944
and Die "Failed to rm file '$backup_dir/ib_logfile*': $!";
948
947
wait_for_ibbackup_suspend();
950
949
#InnoDB data files from original InnoDB data directory
951
950
print STDERR "\n$prefix Starting to backup InnoDB tables and indexes\n";
952
if($option_remote_host) {
953
print STDERR "$prefix to '$backup_dir'\n";
951
print STDERR "$prefix to '$backup_dir'\n";
955
952
print STDERR "$prefix from original InnoDB data directory '$orig_ibdata_dir'\n";
956
953
foreach my $a (split(/;/, $orig_innodb_data_file_path)) {
957
954
my $path = (split(/:/,$a))[0];
958
955
$path=~s/([\$\\\" ])/\\$1/g;
959
if($option_remote_host) {
960
print STDERR "$prefix Backing up file '$orig_ibdata_dir/$path'\n";
961
system("scp $option_scp_opt '$orig_ibdata_dir/$path' '$option_remote_host:$backup_dir/$path'")
962
and Die "Failed to scp file '$path': $!";
963
} elsif($option_stream eq 'tar') {
966
print STDERR "$prefix Backing up as tar stream '$path'\n";
967
if (!$option_tar4ibd) {
968
$tarcmd = "tar chf - -b 32";
971
if ($innodb_use_odirect) {
972
$tarcmd = "$tarcmd -d";
974
$tarcmd = "$tarcmd -c";
976
$ret = system("cd $orig_ibdata_dir; $tarcmd $path") >> 8;
978
print STDERR "$prefix If you use GNU tar, this warning can be ignored.\n";
979
} elsif ($ret != 0) {
980
print STDERR "$prefix tar returned with exit code $ret.\n";
981
if ( -e "$orig_ibdata_dir/$path" ) {
982
Die "Failed to stream '$orig_ibdata_dir/$path': $!";
985
print STDERR "$prefix Ignoring nonexistent file '$orig_ibdata_dir/$path'.\n";
956
print STDERR "$prefix Backing up file '$orig_ibdata_dir/$path'\n";
957
system("scp $option_scp_opt '$orig_ibdata_dir/$path' '$option_remote_host:$backup_dir/$path'")
958
and Die "Failed to scp file '$path': $!";
991
961
#copy *.ibd files
1026
996
if ($print_each_file) {
1027
997
print STDERR "$prefix Backing up file '$file'\n";
1029
if($option_remote_host) {
1030
if (system("ssh $option_ssh_opt $option_remote_host test -e $backup_dir/$subdir")
1032
system("ssh $option_ssh_opt $option_remote_host mkdir $backup_dir/$subdir");
1034
system("scp $option_scp_opt '$file' '$option_remote_host:$backup_dir/$subdir/'")
1035
and Die "Failed to scp file '$file': $!";
1036
} elsif($option_stream eq 'tar') {
1038
my $file_name = substr($file, rindex($file, '/') + 1);
1039
$file_name=~s/([\$\\\" ])/\\$1/g;
1040
if (!$option_tar4ibd) {
1041
$ret = system("cd $orig_datadir; tar chf - -b 32 $subdir/$file_name") >> 8;
1043
$ret = system("cd $orig_datadir; tar4ibd -c $subdir/$file_name") >> 8;
1046
print STDERR "$prefix If you use GNU tar, this warning can be ignored.\n";
1047
} elsif ($ret != 0) {
1048
print STDERR "$prefix tar returned with exit code $ret.\n";
1049
if ( -e "$orig_datadir/$subdir/$file_name" ) {
1050
Die "Failed to stream '$orig_datadir/$subdir/$file_name': $!";
1053
print STDERR "$prefix Ignoring nonexistent file '$orig_datadir/$subdir/$file_name'.\n";
999
if (system("ssh $option_ssh_opt $option_remote_host test -e $backup_dir/$subdir")
1001
system("ssh $option_ssh_opt $option_remote_host mkdir $backup_dir/$subdir");
1003
system("scp $option_scp_opt '$file' '$option_remote_host:$backup_dir/$subdir/'")
1004
and Die "Failed to scp file '$file': $!";
1062
if($option_remote_host || $option_stream) {
1010
if($option_remote_host) {
1063
1011
open(STDOUT, "> $tmp_logfile")
1064
1012
|| Die "Failed to open file '$tmp_logfile': $!"
1277
1225
print FILE "$info_lines[1]\n";
1280
if ($option_stream eq 'tar') {
1281
system("cd $option_tmpdir; tar chf - xtrabackup_binlog_info")
1228
if ($option_stream) {
1229
system("cd $option_tmpdir; $stream_cmd xtrabackup_binlog_info")
1282
1230
and Die "Failed to stream 'xtrabackup_binlog_info': $!";
1283
1231
unlink $binlog_info || Die "Failed to delete '$binlog_info': $!";
1374
1322
print FILE "CHANGE MASTER TO MASTER_LOG_FILE='$filename', MASTER_LOG_POS=$position\n";
1377
if ($option_stream eq 'tar') {
1378
system("cd $option_tmpdir; tar chf - xtrabackup_slave_info")
1325
if ($option_stream) {
1326
system("cd $option_tmpdir; $stream_cmd xtrabackup_slave_info")
1379
1327
and Die "Failed to stream 'xtrabackup_slave_info': $!";
1380
1328
unlink $slave_info || Die "Failed to delete '$slave_info': $!";
1734
1682
if ($option_stream) {
1735
1683
my $filename_dir = dirname($filename);
1736
1684
my $filename_name = basename($filename);
1737
if ($option_stream eq 'tar') {
1738
system("cd $filename_dir; tar chf - $filename_name")
1739
and Die "Failed to stream '$filename_name': $!";
1685
system("cd $filename_dir; $stream_cmd $filename_name")
1686
and Die "Failed to stream '$filename_name': $!";
1741
1688
unlink $filename || Die "Failed to delete '$filename': $!";
1773
1720
# read command line options
1774
$rcode = GetOptions('compress:i' => \$option_compress,
1721
$rcode = GetOptions('compress' => \$option_compress,
1722
'compress-threads=i' => \$option_compress_threads,
1775
1723
'help' => \$option_help,
1776
1724
'version' => \$option_version,
1777
1725
'throttle=i' => \$option_throttle,
1839
1787
$option_compress = 0;
1790
if ($option_stream eq 'tar') {
1791
$stream_cmd = 'tar chf -';
1792
} elsif ($option_stream eq 'xbstream') {
1793
$stream_cmd = 'xbstream -c'
1842
1796
if (@ARGV < 1) {
1843
1797
print STDERR "$prefix Missing command line argument\n";
1850
if ($option_stream) {
1851
if ($option_stream eq 'tar') {
1852
if ( !$option_force_tar ) {
1853
$option_tar4ibd = 'tar4ibd';
1856
print STDERR "Forcing tar instead of tar4ibd\n";
1858
} elsif ($option_stream eq 'tar4ibd') {
1859
$option_stream = 'tar';
1860
$option_tar4ibd = 'tar4ibd';
1861
} elsif ($option_stream eq 'cpio') {
1862
print STDERR "$prefix --stream=cpio is not supported yet\n";
1865
print STDERR "$prefix Unknown option --stream=$option_stream\n";
1870
1804
# get options file name
1871
1805
#$config_file = $ARGV[0];
2107
2041
} elsif ($option_remote_host) {
2108
2042
# Queue up files for one single scp per database.
2109
2043
push(@scp_files, "'$file'");
2110
} elsif($option_stream eq 'tar') {
2044
} elsif($option_stream) {
2112
2046
my $file_name = substr($file, rindex($file, '/') + 1);
2113
2047
$file_name=~s/([\$\\\" ])/\\$1/g;
2114
$ret = system("cd $source_dir; tar cf - $database/$file_name") >> 8;
2048
$ret = system("cd $source_dir; $stream_cmd $database/$file_name") >> 8;
2049
if ($ret == 1 && $option_stream eq 'tar') {
2116
2050
print STDERR "$prefix If you use GNU tar, this warning can be ignored.\n";
2117
2051
# Check for non-zero exit code
2118
2052
} elsif ($ret != 0) {
2119
print STDERR "$prefix tar returned with exit code $ret.\n";
2053
print STDERR "$prefix $stream_cmd returned with exit code $ret.\n";
2120
2054
# Only treat as fatal cases where the file exists
2121
2055
if ( -e "$database/$file_name" ) {
2122
2056
Die "Failed to stream '$database/$file_name': $!";
2683
2618
=head1 SYNOPOSIS
2685
innobackupex [--compress[=LEVEL]] [--include=REGEXP] [--user=NAME]
2620
innobackupex [--compress] [--compress-threads=NUMBER-OF-THREADS]
2621
[--include=REGEXP] [--user=NAME]
2686
2622
[--password=WORD] [--port=PORT] [--socket=SOCKET]
2687
2623
[--no-timestamp] [--ibbackup=IBBACKUP-BINARY]
2688
[--slave-info] [--stream=tar] [--force-tar]
2689
[--scpopt=OPTIONS-FOR-SCP] [--sshopt=OPTIONS-FOR-SSH]
2624
[--slave-info] [--stream=tar|xbstream] [--force-tar]
2625
[--scpopt=OPTIONS-FOR-SCP] [--sshopt=OPTIONS-FOR-SSH]
2690
2626
[--defaults-file=MY.CNF]
2691
2627
[--databases=LIST] [--remote-host=HOSTNAME] [--no-lock]
2692
2628
[--tmpdir=DIRECTORY] [--tables-file=FILE]
2742
2678
Prepare a backup in BACKUP-DIR by applying the transaction log file named "xtrabackup_logfile" located in the same directory. Also, create new transaction logs. The InnoDB configuration is read from the file "backup-my.cnf".
2682
This option instructs xtrabackup to compress backup copies of InnoDB
2683
data files. It is passed directly to the xtrabackup child process. Try
2684
'xtrabackup --help' for more details.
2686
=item --compress-threads
2688
This option specifies the number of worker threads that will be used
2689
for parallel compression. It is passed directly to the xtrabackup
2690
child process. Try 'xtrabackup --help' for more details.
2744
2692
=item --copy-back
2746
2694
Copy all the files in a previously made backup from the backup directory to their original locations.
2853
2801
=item --stream=[tar|. . .]
2855
This option specifies the format in which to do the streamed backup. The option accepts a string argument. The backup will be done to STDOUT in the specified format. Currently, the only supported format is tar. Uses tar4ibd, which is available in XtraBackup distributions.
2803
This option specifies the format in which to do the streamed backup. The option accepts a string argument. The backup will be done to STDOUT in the specified format. Currently, the only supported formats are tar and xbstream. This option is passed directly to xtrabackup's --stream option.
2857
2805
=item --tables-file=FILE