Commit f8c3d4c2 authored by Vlad Lesin's avatar Vlad Lesin

MDEV-28187 mariadb-backup doesn't utilise innodb-undo-log-directory (if...

MDEV-28187 mariadb-backup doesn't utilise innodb-undo-log-directory (if specified as a relative path) during copy-back operation

Make absolute destination path from relative one, basing on mysql data
directory.

Reviewed by Alexander Barkov.
parent a2cb6d87
......@@ -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);
......
......@@ -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
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;
--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;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment