summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-04-11 23:07:23 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2018-04-12 11:15:27 +0100
commit15071226a04125976e19a552103821eeb7227d75 (patch)
tree13ae44d66f5e43d76f122e6df996e0c6d488342e /extra
parent0ae13b51d780d4c0e2ef6fc251a8e03140663d35 (diff)
downloadmariadb-git-15071226a04125976e19a552103821eeb7227d75.tar.gz
MDEV-15780 : Mariabackup with absolute paths in innodb_data_file_path
System tablespace can be specified with absolute path, if innodb_data_home_dir is empty. This was not handled well by mariabackup 1. In backup phase, empty innodb_data_home_dir variable from server was not recognized. full paths were stored in backup-my.ini, even if it stored all files locally. thus prepare phase would not find the system tablespace files. 2. In copy-back phase, copy would not be done to the absolute destination path, as path would be stripped with trim_dotslash This patch fixes the above defects.
Diffstat (limited to 'extra')
-rw-r--r--extra/mariabackup/backup_copy.cc6
-rw-r--r--extra/mariabackup/backup_mysql.cc42
2 files changed, 44 insertions, 4 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index c019209faad..d3253348d72 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -975,6 +975,9 @@ copy_file(ds_ctxt_t *datasink,
datafile_cur_t cursor;
xb_fil_cur_result_t res;
const char *action;
+ const char *dst_path =
+ (xtrabackup_copy_back || xtrabackup_move_back)?
+ dst_file_path : trim_dotslash(dst_file_path);
if (!datafile_open(src_file_path, &cursor, thread_n)) {
goto error_close;
@@ -982,8 +985,7 @@ copy_file(ds_ctxt_t *datasink,
strncpy(dst_name, cursor.rel_path, sizeof(dst_name));
- dstfile = ds_open(datasink, trim_dotslash(dst_file_path),
- &cursor.statinfo);
+ dstfile = ds_open(datasink, dst_path, &cursor.statinfo);
if (dstfile == NULL) {
msg("[%02u] error: "
"cannot open the destination stream for %s\n",
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc
index 6f425e9419f..661992a1696 100644
--- a/extra/mariabackup/backup_mysql.cc
+++ b/extra/mariabackup/backup_mysql.cc
@@ -477,7 +477,7 @@ get_mysql_vars(MYSQL *connection)
innodb_data_file_path_var, MYF(MY_FAE));
}
- if (innodb_data_home_dir_var && *innodb_data_home_dir_var) {
+ if (innodb_data_home_dir_var) {
innobase_data_home_dir = my_strdup(
innodb_data_home_dir_var, MYF(MY_FAE));
}
@@ -1521,6 +1521,44 @@ cleanup:
extern const char *innodb_checksum_algorithm_names[];
+#ifdef _WIN32
+#include <algorithm>
+#endif
+
+static std::string make_local_paths(const char *data_file_path)
+{
+ if (strchr(data_file_path, '/') == 0
+#ifdef _WIN32
+ && strchr(data_file_path, '\\') == 0
+#endif
+ ){
+ return std::string(data_file_path);
+ }
+
+ std::ostringstream buf;
+
+ char *dup = strdup(innobase_data_file_path);
+ ut_a(dup);
+ char *p;
+ char * token = strtok_r(dup, ";", &p);
+ while (token) {
+ if (buf.tellp())
+ buf << ";";
+
+ char *fname = strrchr(token, '/');
+#ifdef _WIN32
+ fname = std::max(fname,strrchr(token, '\\'));
+#endif
+ if (fname)
+ buf << fname + 1;
+ else
+ buf << token;
+ token = strtok_r(NULL, ";", &p);
+ }
+ free(dup);
+ return buf.str();
+}
+
bool write_backup_config_file()
{
int rc= backup_file_printf("backup-my.cnf",
@@ -1541,7 +1579,7 @@ bool write_backup_config_file()
"%s\n",
innodb_checksum_algorithm_names[srv_checksum_algorithm],
innodb_checksum_algorithm_names[srv_log_checksum_algorithm],
- innobase_data_file_path,
+ make_local_paths(innobase_data_file_path).c_str(),
srv_n_log_files,
innobase_log_file_size,
srv_page_size,