mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-12956 provide default datadir for mariabackup --copy-back
On Unix, it is compiled-in datadir value. On Windows, the directory is ..\data, relative to directory mariabackup.exe server uses the same logic to determine datadir.
This commit is contained in:
parent
21829bd743
commit
e46b2a3e94
1 changed files with 33 additions and 2 deletions
|
@ -443,6 +443,38 @@ datafiles_iter_free(datafiles_iter_t *it)
|
|||
ut_free(it);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Retrieve default data directory, to be used with --copy-back.
|
||||
|
||||
On Windows, default datadir is ..\data, relative to the
|
||||
directory where mariabackup.exe is located(usually "bin")
|
||||
|
||||
Elsewhere, the compiled-in constant MYSQL_DATADIR is used.
|
||||
*/
|
||||
static char *get_default_datadir() {
|
||||
static char ddir[] = MYSQL_DATADIR;
|
||||
#ifdef _WIN32
|
||||
static char buf[MAX_PATH];
|
||||
DWORD size = (DWORD)sizeof(buf) - 1;
|
||||
if (GetModuleFileName(NULL, buf, size) <= size)
|
||||
{
|
||||
char *p;
|
||||
if ((p = strrchr(buf, '\\')))
|
||||
{
|
||||
*p = 0;
|
||||
if ((p = strrchr(buf, '\\')))
|
||||
{
|
||||
strncpy(p + 1, "data", buf + MAX_PATH - p);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ddir;
|
||||
}
|
||||
|
||||
|
||||
/* ======== Date copying thread context ======== */
|
||||
|
||||
typedef struct {
|
||||
|
@ -6764,8 +6796,7 @@ int main(int argc, char **argv)
|
|||
|
||||
if (xtrabackup_copy_back || xtrabackup_move_back) {
|
||||
if (!check_if_param_set("datadir")) {
|
||||
msg("Error: datadir must be specified.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
mysql_data_home = get_default_datadir();
|
||||
}
|
||||
if (!copy_back())
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
Loading…
Reference in a new issue