summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extra/mariabackup/backup_copy.cc6
-rw-r--r--extra/mariabackup/backup_mysql.cc42
-rw-r--r--mysql-test/suite/mariabackup/absolute_ibdata_paths.opt1
-rw-r--r--mysql-test/suite/mariabackup/absolute_ibdata_paths.result10
-rw-r--r--mysql-test/suite/mariabackup/absolute_ibdata_paths.test31
5 files changed, 86 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,
diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt
new file mode 100644
index 00000000000..52b6b743ac8
--- /dev/null
+++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt
@@ -0,0 +1 @@
+--innodb --innodb-data-home-dir= --innodb-data-file-path=$MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1:3M;ibdata_second:1M:autoextend \ No newline at end of file
diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.result b/mysql-test/suite/mariabackup/absolute_ibdata_paths.result
new file mode 100644
index 00000000000..fe211e71f2f
--- /dev/null
+++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.result
@@ -0,0 +1,10 @@
+CREATE TABLE t(i INT) ENGINE INNODB;
+INSERT INTO t VALUES(1);
+# xtrabackup backup
+# remove datadir
+# xtrabackup copy back
+# restart server
+SELECT * from t;
+i
+1
+DROP TABLE t;
diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.test b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test
new file mode 100644
index 00000000000..6717f16d199
--- /dev/null
+++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test
@@ -0,0 +1,31 @@
+# This test just backs up and restores empty database
+# Innodb system tablespace is specified with absolute path in the .opt file
+CREATE TABLE t(i INT) ENGINE INNODB;
+INSERT INTO t VALUES(1);
+echo # xtrabackup backup;
+
+let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
+let $_innodb_data_file_path=`select @@innodb_data_file_path`;
+let $_innodb_data_home_dir=`select @@innodb_data_home_dir`;
+let $_datadir= `SELECT @@datadir`;
+
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
+--enable_result_log
+exec $XTRABACKUP --prepare --target-dir=$targetdir;
+
+--source include/shutdown_mysqld.inc
+echo # remove datadir;
+rmdir $_datadir;
+#remove out-of-datadir ibdata1
+remove_file $MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1;
+echo # xtrabackup copy back;
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir "--innodb_data_file_path=$_innodb_data_file_path" --innodb_data_home_dir=$_innodb_data_home_dir;
+echo # restart server;
+--source include/start_mysqld.inc
+--enable_result_log
+
+SELECT * from t;
+DROP TABLE t;
+rmdir $targetdir;
+