summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extra/mariabackup/backup_copy.cc27
-rw-r--r--mysql-test/suite/mariabackup/include/restart_and_restore.inc2
-rw-r--r--mysql-test/suite/mariabackup/relative_path.opt1
-rw-r--r--mysql-test/suite/mariabackup/relative_path.result20
-rw-r--r--mysql-test/suite/mariabackup/relative_path.test35
5 files changed, 77 insertions, 8 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index e7d69a25b76..608be7125bd 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -1816,13 +1816,28 @@ apply_log_finish()
return(true);
}
+class Copy_back_dst_dir
+{
+ std::string buf;
+
+public:
+ const char *make(const char *path)
+ {
+ if (!path || !path[0])
+ return mysql_data_home;
+ if (is_absolute_path(path))
+ return path;
+ return buf.assign(mysql_data_home).append(path).c_str();
+ }
+};
+
bool
copy_back()
{
bool ret = false;
datadir_iter_t *it = NULL;
datadir_node_t node;
- char *dst_dir;
+ const char *dst_dir;
memset(&node, 0, sizeof(node));
@@ -1875,9 +1890,9 @@ copy_back()
/* copy undo tablespaces */
+ Copy_back_dst_dir dst_dir_buf;
- dst_dir = (srv_undo_dir && *srv_undo_dir)
- ? srv_undo_dir : mysql_data_home;
+ dst_dir = dst_dir_buf.make(srv_undo_dir);
ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
@@ -1898,8 +1913,7 @@ copy_back()
/* copy redo logs */
- dst_dir = (srv_log_group_home_dir && *srv_log_group_home_dir)
- ? srv_log_group_home_dir : mysql_data_home;
+ dst_dir = dst_dir_buf.make(srv_log_group_home_dir);
/* --backup generates a single ib_logfile0, which we must copy
if it exists. */
@@ -1926,8 +1940,7 @@ copy_back()
/* copy innodb system tablespace(s) */
- dst_dir = (innobase_data_home_dir && *innobase_data_home_dir)
- ? innobase_data_home_dir : mysql_data_home;
+ dst_dir = dst_dir_buf.make(innobase_data_home_dir);
ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
diff --git a/mysql-test/suite/mariabackup/include/restart_and_restore.inc b/mysql-test/suite/mariabackup/include/restart_and_restore.inc
index 2d1e5493957..aa26d28efba 100644
--- a/mysql-test/suite/mariabackup/include/restart_and_restore.inc
+++ b/mysql-test/suite/mariabackup/include/restart_and_restore.inc
@@ -4,5 +4,5 @@ echo # shutdown server;
echo # remove datadir;
rmdir $_datadir;
echo # xtrabackup move back;
-exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir --parallel=2 --throttle=1;
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir --parallel=2 --throttle=1 $backup_opts;
--source include/start_mysqld.inc
diff --git a/mysql-test/suite/mariabackup/relative_path.opt b/mysql-test/suite/mariabackup/relative_path.opt
new file mode 100644
index 00000000000..3e3c33e44f8
--- /dev/null
+++ b/mysql-test/suite/mariabackup/relative_path.opt
@@ -0,0 +1 @@
+--innodb-undo-tablespaces=2
diff --git a/mysql-test/suite/mariabackup/relative_path.result b/mysql-test/suite/mariabackup/relative_path.result
new file mode 100644
index 00000000000..7aa0c6968f3
--- /dev/null
+++ b/mysql-test/suite/mariabackup/relative_path.result
@@ -0,0 +1,20 @@
+CREATE TABLE t(i INT) ENGINE INNODB;
+INSERT INTO t VALUES(1);
+# xtrabackup backup
+# xtrabackup prepare
+# shutdown server
+# remove datadir
+# xtrabackup move back
+# restart
+# shutdown server
+# remove datadir
+# xtrabackup move back
+# restart
+# shutdown server
+# remove datadir
+# xtrabackup move back
+# restart
+SELECT * FROM t;
+i
+1
+DROP TABLE t;
diff --git a/mysql-test/suite/mariabackup/relative_path.test b/mysql-test/suite/mariabackup/relative_path.test
new file mode 100644
index 00000000000..bd25a217e71
--- /dev/null
+++ b/mysql-test/suite/mariabackup/relative_path.test
@@ -0,0 +1,35 @@
+--source include/have_innodb.inc
+
+CREATE TABLE t(i INT) ENGINE INNODB;
+INSERT INTO t VALUES(1);
+
+echo # xtrabackup backup;
+let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
+--let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log
+
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backup_log 2>&1;
+--enable_result_log
+
+echo # xtrabackup prepare;
+--disable_result_log
+exec $XTRABACKUP --prepare --target-dir=$targetdir;
+
+# If MDEV-28187 is not fixed, the following tries to copy backup to data
+# directory will fail, because their destination path will be the same as
+# their source path
+
+--let $backup_opts=--innodb_undo_directory=./
+--source include/restart_and_restore.inc
+
+--let $backup_opts=--innodb_log_group_home_dir=./
+--source include/restart_and_restore.inc
+
+--let $backup_opts=--innodb_data_home_dir=./
+--source include/restart_and_restore.inc
+
+--enable_result_log
+
+SELECT * FROM t;
+DROP TABLE t;
+rmdir $targetdir;