288
288
#define SRV_PATH_SEPARATOR '\\'
289
#define SRV_PATH_SEPARATOR_STR "\\"
291
290
#define SRV_PATH_SEPARATOR '/'
292
#define SRV_PATH_SEPARATOR_STR "/"
295
293
#ifndef UNIV_PAGE_SIZE_MAX
3120
3118
p = srv_data_file_names[i];
3121
while ((p = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)
3119
while ((p = strchr(p, SRV_PATH_SEPARATOR)) != NULL)
3124
3122
srv_data_file_names[i] = p;
3656
3654
/************************************************************************
3657
Checks if a table specified as a path should be skipped from backup
3658
based on the --tables or --tables-file options.
3655
Checks if a table specified as a name in the form "database/name" (InnoDB 5.6)
3656
or "./database/name.ibd" (InnoDB 5.5-) should be skipped from backup based on
3657
the --tables or --tables-file options.
3660
3659
@return TRUE if the table should be skipped. */
3662
check_if_skip_table(const char *path, const char *suffix)
3661
check_if_skip_table(const char *name)
3664
3663
char buf[FN_REFLEN];
3665
3664
const char *dbname, *tbname;
3666
3665
const char *ptr;
3670
3668
if (xtrabackup_tables == NULL && xtrabackup_tables_file == NULL) {
3676
while ((ptr = strstr(tbname, SRV_PATH_SEPARATOR_STR)) != NULL) {
3674
while ((ptr = strchr(tbname, SRV_PATH_SEPARATOR)) != NULL) {
3677
3675
dbname = tbname;
3678
3676
tbname = ptr + 1;
3685
3683
strncpy(buf, dbname, FN_REFLEN);
3686
buf[FN_REFLEN - 1] = 0;
3684
buf[FN_REFLEN - 1] = '\0';
3687
3685
buf[tbname - 1 - dbname] = '.';
3689
dbname_len = strlen(dbname) - strlen(suffix);
3690
if (dbname_len < 1) {
3687
/* Check if there's a suffix in the table name. If so, truncate it. We
3688
rely on the fact that a dot cannot be a part of a table name (it is
3689
encoded by the server with the @NNNN syntax). */
3690
if ((eptr = strchr(&buf[tbname - dbname], '.')) != NULL) {
3693
buf[dbname_len - 1] = 0;
3695
3695
/* For partitioned tables first try to match against the regexp
3696
3696
without truncating the #P#... suffix so we can backup individual
3968
/***********************************************************************
3969
Extracts the relative path ("database/table.ibd") of a tablespace from a
3970
specified possibly absolute path.
3972
For user tablespaces both "./database/table.ibd" and
3973
"/remote/dir/database/table.ibd" result in "database/table.ibd".
3975
For system tablepsaces (i.e. When is_system is TRUE) both "/remote/dir/ibdata1"
3976
and "./ibdata1" yield "ibdata1" in the output. */
3979
xb_get_relative_path(
3980
/*=================*/
3981
const char* path, /*!< in: tablespace path (either
3982
relative or absolute) */
3983
ibool is_system) /*!< in: TRUE for system tablespaces,
3984
i.e. when only the filename must be
3994
while ((next = strchr(cur, SRV_PATH_SEPARATOR)) != NULL) {
4005
return((prev == NULL) ? cur : prev);
3968
4010
/* TODO: We may tune the behavior (e.g. by fil_aio)*/
3969
4011
#define COPY_CHUNK 64
3990
4032
xb_delta_info_t info;
3991
4033
datasink_t *ds = ds_ctxt->datasink;
3992
4034
ds_file_t *dstfile = NULL;
4037
/* Get the name and the path for the tablespace. node->name always
4038
contains the path (which may be absolute for remote tablespaces in
4039
5.6+). space->name contains the tablespace name in the form
4040
"./database/table.ibd" (in 5.5-) or "database/table" (in 5.6+). For a
4041
multi-node shared tablespace, space->name contains the name of the first
4042
node, but that's irrelevant, since we only need node_name to match them
4043
against filters, and the shared tablespace is always copied regardless
4044
of the filters value. */
4046
const char* const node_name = node->space->name;
4047
const char* const node_path = node->name;
3994
4049
info.page_size = 0;
3995
4050
info.zip_size = 0;
3996
4051
info.space_id = 0;
3998
if ((!trx_sys_sys_space(node->space->id))
3999
&& check_if_skip_table(node->name, "ibd")) {
4000
msg("[%02u] Skipping %s.\n", thread_n, node->name);
4053
is_system = trx_sys_sys_space(node->space->id);
4055
if (!is_system && check_if_skip_table(node_name)) {
4056
msg("[%02u] Skipping %s.\n", thread_n, node_name);
4004
if (trx_sys_sys_space(node->space->id))
4007
/* system datafile "/fullpath/datafilename.ibd" or "./datafilename.ibd" */
4009
while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)
4013
strncpy(dst_name, p, sizeof(dst_name));
4015
/* file per table style "./database/table.ibd" */
4016
strncpy(dst_name, node->name, sizeof(dst_name));
4060
/* Get the relative path for the destination tablespace name. Non-system
4061
tablespaces may have absolute paths for remote tablespaces in MySQL
4062
5.6+. We want to make "local" copies for the backup. We don't use
4063
node_name here, because in MySQL 5.6+ it doesn't contain the .ibd
4065
strncpy(dst_name, xb_get_relative_path(node_path, is_system),
4019
4068
/* open src_file*/
4020
src_file = xb_file_create_no_error_handling(node->name,
4069
src_file = xb_file_create_no_error_handling(node_path,
4022
4071
OS_FILE_READ_ONLY,
4029
4078
"[%02u] xtrabackup: Warning: We assume the "
4030
4079
"table was dropped or renamed during "
4031
4080
"xtrabackup execution and ignore the file.\n",
4032
thread_n, node->name, thread_n);
4081
thread_n, node_path, thread_n);
4036
xb_file_set_nocache(src_file, node->name, "OPEN");
4085
xb_file_set_nocache(src_file, node_path, "OPEN");
4038
4087
#ifdef USE_POSIX_FADVISE
4039
4088
posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);
4050
4099
page_size = info.zip_size;
4051
4100
page_size_shift = get_bit_shift(page_size);
4052
4101
msg("[%02u] %s is compressed with page size = "
4053
"%lu bytes\n", thread_n, node->name, page_size);
4102
"%lu bytes\n", thread_n, node_name, page_size);
4054
4103
if (page_size_shift < 10 || page_size_shift > 14) {
4055
4104
msg("[%02u] xtrabackup: Error: Invalid "
4056
4105
"page size: %lu.\n", thread_n, page_size);
4088
4137
info.page_size = 0;
4090
if (my_stat(node->name, &src_stat, MYF(MY_WME)) == NULL) {
4139
if (my_stat(node_path, &src_stat, MYF(MY_WME)) == NULL) {
4091
4140
msg("[%02u] xtrabackup: Warning: cannot stat %s\n",
4092
thread_n, node->name);
4141
thread_n, node_path);
4095
4144
dstfile = ds->open(ds_ctxt, dst_name, &src_stat);
4103
4152
if (xtrabackup_stream) {
4104
4153
const char *action = xtrabackup_compress ?
4105
4154
"Compressing and streaming" : "Streaming";
4106
msg("[%02u] %s %s\n", thread_n, action, node->name);
4155
msg("[%02u] %s %s\n", thread_n, action, node_path);
4108
4157
const char *action;
4113
4162
action = "Copying";
4115
4164
msg("[%02u] %s %s to %s\n", thread_n, action,
4116
node->name, dstfile->path);
4165
node_path, dstfile->path);
4119
4168
buf2 = static_cast<byte *>(ut_malloc(COPY_CHUNK
4305
4354
msg("[%02u] xtrabackup: Warning: We assume the "
4306
4355
"table was dropped during xtrabackup execution "
4307
4356
"and ignore the file.\n", thread_n);
4308
msg("[%02u] xtrabackup: Warning: skipping file %s.\n",
4309
thread_n, node->name);
4357
msg("[%02u] xtrabackup: Warning: skipping tablespace %s.\n",
4358
thread_n, node_name);