85
85
my $option_sleep = '';
86
86
my $option_compress = 999;
87
87
my $option_compress_threads = 1;
88
my $option_compress_chunk_size = '';
89
my $option_encrypt = '';
90
my $option_encrypt_key = '';
91
my $option_encrypt_key_file = '';
93
my $option_encrypt_threads = 1;
94
my $option_encrypt_chunk_size = '';
88
95
my $option_uncompress = '';
89
96
my $option_export = '';
90
97
my $option_use_memory = '';
298
305
close XTRABACKUP_BINARY;
300
307
if ($option_stream) {
301
system("cd $option_tmpdir; $stream_cmd $xtrabackup_binary_file")
302
&& die "Failed to stream $xtrabackup_binary_file: $!";
308
stream_encrypt_file($option_tmpdir, $xtrabackup_binary_file)
309
&& die "Failed to stream $xtrabackup_binary_file: $!";
303
310
unlink "$option_tmpdir/$xtrabackup_binary_file";
420
427
if (-e "$orig_datadir/ib_lru_dump") {
421
428
if ($option_stream) {
422
429
print STDERR "$prefix Backing up as tar stream 'ib_lru_dump'\n";
423
system("cd $orig_datadir; $stream_cmd ib_lru_dump")
424
and Die "Failed to stream 'ib_lru_dump': $!";
430
stream_encrypt_file($orig_datadir, "ib_lru_dump")
431
and Die "Failed to stream 'ib_lru_dump': $!";
425
432
} elsif (!$option_rsync) {
426
433
my $src_name = escape_path("$orig_datadir/ib_lru_dump");
427
434
my $dst_name = escape_path("$backup_dir/ib_lru_dump");
996
1003
#(datadir) for 'xtrabackup_suspended' and 'xtrabackup_checkpoints'
997
1004
$options = $options . " --target-dir=" . $option_tmpdir;
999
$options = $options . " --target-dir=$backup_dir";
1006
$options = $options . " --target-dir=$backup_dir";
1002
1009
if ($option_tmpdir) {
1013
1020
if ($option_compress) {
1014
1021
$options = $options . " --compress";
1015
1022
$options = $options . " --compress-threads=$option_compress_threads";
1023
if ($option_compress_chunk_size) {
1024
$options = $options . " --compress-chunk-size=$option_compress_chunk_size";
1027
if ($option_encrypt) {
1028
$options = $options . " --encrypt=$option_encrypt";
1029
if ($option_encrypt_key) {
1030
$options = $options . " --encrypt-key=$option_encrypt_key";
1032
if ($option_encrypt_key_file) {
1033
$options = $options . " --encrypt-key-file=$option_encrypt_key_file";
1035
$options = $options . " --encrypt-threads=$option_encrypt_threads";
1036
if ($option_encrypt_chunk_size) {
1037
$options = $options . " --encrypt-chunk-size=$option_encrypt_chunk_size";
1017
1040
if ($option_use_memory) {
1018
1041
$options = $options . " --use-memory=$option_use_memory";
1027
1050
if ($option_incremental) {
1028
1051
if($option_incremental_lsn) {
1029
1052
$options = $options . " --incremental-lsn='$option_incremental_lsn'";
1031
1054
$options = $options . " --incremental-basedir='$incremental_basedir'";
1035
1058
if ($option_tables_file) {
1321
1344
if ($option_stream) {
1322
system("cd $option_tmpdir; $stream_cmd xtrabackup_binlog_info")
1323
and Die "Failed to stream 'xtrabackup_binlog_info': $!";
1345
stream_encrypt_file($option_tmpdir, "xtrabackup_binlog_info")
1346
and Die "Failed to stream 'xtrabackup_binlog_info': $!";
1324
1347
unlink $binlog_info || Die "Failed to delete '$binlog_info': $!";
1352
1375
if ($option_stream) {
1353
system("cd $option_tmpdir; $stream_cmd xtrabackup_galera_info")
1354
and Die "Failed to stream 'xtrabackup_galera_info': $!";
1376
stream_encrypt_file($option_tmpdir, "xtrabackup_galera_info")
1377
and Die "Failed to stream 'xtrabackup_galera_info': $!";
1355
1378
unlink $galera_info || Die "Failed to delete '$galera_info': $!";
1393
1416
if ($option_stream) {
1394
system("cd $option_tmpdir; $stream_cmd xtrabackup_slave_info")
1395
and Die "Failed to stream 'xtrabackup_slave_info': $!";
1417
stream_encrypt_file($option_tmpdir, "xtrabackup_slave_info")
1418
and Die "Failed to stream 'xtrabackup_slave_info': $!";
1396
1419
unlink $slave_info || Die "Failed to delete '$slave_info': $!";
1687
1710
if ($option_stream) {
1688
1711
my $filename_dir = dirname($filename);
1689
1712
my $filename_name = basename($filename);
1690
system("cd $filename_dir; $stream_cmd $filename_name")
1691
and Die "Failed to stream '$filename_name': $!";
1713
stream_encrypt_file($filename_dir, $filename_name)
1714
and Die "Failed to stream '$filename_name': $!";
1693
1715
unlink $filename || Die "Failed to delete '$filename': $!";
1725
1747
# read command line options
1726
1748
$rcode = GetOptions('compress' => \$option_compress,
1727
'compress-threads=i' => \$option_compress_threads,
1749
'compress-threads=i' => \$option_compress_threads,
1750
'compress-chunk-size=s' => \$option_compress_chunk_size,
1751
'encrypt=s' => \$option_encrypt,
1752
'encrypt-key=s' => \$option_encrypt_key,
1753
'encrypt-key-file=s' => \$option_encrypt_key_file,
1754
'encrypt-threads=i' => \$option_encrypt_threads,
1755
'encrypt-chunk-size=s' => \$option_encrypt_chunk_size,
1728
1756
'help' => \$option_help,
1729
1757
'version' => \$option_version,
1730
1758
'throttle=i' => \$option_throttle,
1756
1784
'incremental-dir=s' => \$option_incremental_dir,
1757
1785
'extra-lsndir=s' => \$option_extra_lsndir,
1758
1786
'stream=s' => \$option_stream,
1759
'rsync' => \$option_rsync,
1787
'rsync' => \$option_rsync,
1760
1788
'tmpdir=s' => \$option_tmpdir,
1761
1789
'no-lock' => \$option_no_lock,
1762
1790
'ibbackup=s' => \$option_ibbackup_binary,
1802
1830
if ($option_compress == 999) {
1803
1831
# compress option not given in the command line
1804
$option_compress = 0;
1832
$option_compress = 0;
1807
1835
if ($option_stream eq 'tar') {
1808
1836
$stream_cmd = 'tar chf -';
1809
1837
} elsif ($option_stream eq 'xbstream') {
1810
$stream_cmd = 'xbstream -c'
1838
$stream_cmd = 'xbstream -c';
1839
if ($option_encrypt) {
1840
$encrypt_cmd = "xbcrypt --encrypt-algo=$option_encrypt";
1841
if ($option_encrypt_key) {
1842
$encrypt_cmd = $encrypt_cmd . " --encrypt-key=$option_encrypt_key";
1844
if ($option_encrypt_key_file) {
1845
$encrypt_cmd = $encrypt_cmd . " --encrypt-key-file=$option_encrypt_key_file";
1847
if ($option_encrypt_chunk_size) {
1848
$encrypt_cmd = $encrypt_cmd . " --encrypt-chunk-size=$option_encrypt_chunk_size";
1813
1853
if (@ARGV < 1) {
2048
2088
my $file_name = substr($file, rindex($file, '/') + 1);
2049
2089
$file_name=~s/([\$\\\" ])/\\$1/g;
2050
$ret = system("cd $source_dir; $stream_cmd $database/$file_name") >> 8;
2090
$ret = stream_encrypt_file($source_dir, "$database/$file_name") >> 8;
2051
2091
if ($ret == 1 && $option_stream eq 'tar') {
2052
2092
print STDERR "$prefix If you use GNU tar, this warning can be ignored.\n";
2053
2093
# Check for non-zero exit code
2673
2713
return $con->{status}->{Slave_open_temp_tables}->{Value};
2716
sub stream_encrypt_file {
2717
my $basedir = shift;
2718
my $relpath = shift;
2722
$rcode = system("cd $basedir; $stream_cmd $relpath | $encrypt_cmd");
2724
$rcode = system("cd $basedir; $stream_cmd $relpath");
2682
2736
=head1 SYNOPOSIS
2684
innobackupex [--compress] [--compress-threads=NUMBER-OF-THREADS]
2738
innobackupex [--compress] [--compress-threads=NUMBER-OF-THREADS] [--compress-chunk-size=CHUNK-SIZE]
2739
[--encrypt=encryption_algorithm] [--encrypt-threads=NUMBER-OF-THREADS] [--encrypt-chunk-size=CHUNK-SIZE]
2740
[--encrypt-key=literal_encryption_key] | [--encryption-key-file=MY.KEY]
2685
2741
[--include=REGEXP] [--user=NAME]
2686
2742
[--password=WORD] [--port=PORT] [--socket=SOCKET]
2687
2743
[--no-timestamp] [--ibbackup=IBBACKUP-BINARY]
2765
2821
for parallel compression. It is passed directly to the xtrabackup
2766
2822
child process. Try 'xtrabackup --help' for more details.
2824
=item --compress-chunk-size
2826
This option specifies the size of the internal working buffer for each
2827
compression thread, measured in kilobytes. It is passed directly to the
2828
xtrabackup child process. Try 'xtrabackup --help' for more details.
2768
2830
=item --copy-back
2770
2832
Copy all the files in a previously made backup from the backup directory to their original locations.
2782
2844
This option specifies what extra file to read the default MySQL options from before the standard defaults-file. The option accepts a string argument. It is also passed directly to xtrabackup's --defaults-extra-file option. See the xtrabackup documentation for details.
2846
=item --encrypt=ENCRYPTION_ALGORITHM
2848
This option instructs xtrabackup to encrypt backup copies of InnoDB data
2849
files using the algorithm specified in the ENCRYPTION_ALGORITHM.
2850
It is passed directly to the xtrabackup child process.
2851
Try 'xtrabackup --help' for more details.
2853
=item --encrypt-key=ENCRYPTION_KEY
2855
This option instructs xtrabackup to use the given ENCRYPTION_KEY when using the --encrypt option.
2856
It is passed directly to the xtrabackup child process.
2857
Try 'xtrabackup --help' for more details.
2859
=item --encrypt-key-file=ENCRYPTION_KEY_FILE
2861
This option instructs xtrabackup to use the encryption key stored in the given ENCRYPTION_KEY_FILE when using the --encrypt option.
2862
It is passed directly to the xtrabackup child process.
2863
Try 'xtrabackup --help' for more details.
2865
=item --encrypt-threads
2867
This option specifies the number of worker threads that will be used
2868
for parallel encryption. It is passed directly to the xtrabackup
2869
child process. Try 'xtrabackup --help' for more details.
2871
=item --encrypt-chunk-size
2873
This option specifies the size of the internal working buffer for each
2874
encryption thread, measured in kilobytes. It is passed directly to the
2875
xtrabackup child process. Try 'xtrabackup --help' for more details.
2786
2879
This option is passed directly to xtrabackup's --export option. It enables exporting individual tables for import into another server. See the xtrabackup documentation for details.