diff options
author | Alexander Barkov <bar@mariadb.com> | 2023-02-03 07:42:59 +0400 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2023-03-10 12:41:58 +0100 |
commit | b314f7b6420069a01d64b33fa461f0914feb8638 (patch) | |
tree | 967d2ad254301d86c8676e4511ba24b75a025a3d /extra | |
parent | 4ae97333f08b58d1934e0c7804732e7ad2eca39b (diff) | |
download | mariadb-git-b314f7b6420069a01d64b33fa461f0914feb8638.tar.gz |
MDEV-18931 Rename Mariabackup's xtrabackup_* files to mariadb_backup_*
Renaming the default MariaDB backup directory from
xtrabackup_backupfiles to mariadb_backup_files.
Renaming files:
- xtrabackup_binlog_info to mariadb_backup_binlog_info
- xtrabackup_checkpoints to mariadb_backup_checkpoints
- xtrabackup_galera_info to mariadb_backup_galera_info
- xtrabackup_info to mariadb_backup_info
- xtrabackup_slave_info to mariadb_backup_slave_info
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/backup_copy.cc | 22 | ||||
-rw-r--r-- | extra/mariabackup/backup_copy.h | 10 | ||||
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 16 | ||||
-rw-r--r-- | extra/mariabackup/backup_wsrep.h | 2 | ||||
-rw-r--r-- | extra/mariabackup/innobackupex.cc | 8 | ||||
-rw-r--r-- | extra/mariabackup/wsrep.cc | 12 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 83 |
7 files changed, 93 insertions, 60 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index c3b909fc9b9..da77c651c88 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1557,7 +1557,7 @@ bool backup_finish() return(false); } - if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, + if (!write_xtrabackup_info(mysql_connection, MB_INFO, opt_history != 0, true)) { return(false); } @@ -1613,10 +1613,14 @@ ibx_copy_incremental_over_full() const char *ext_list[] = {"frm", "isl", "MYD", "MYI", "MAD", "MAI", "MRG", "TRG", "TRN", "ARM", "ARZ", "CSM", "CSV", "opt", "par", NULL}; - const char *sup_files[] = {"xtrabackup_binlog_info", - "xtrabackup_galera_info", - "xtrabackup_slave_info", - "xtrabackup_info", + const char *sup_files[] = {MB_BINLOG_INFO, + MB_GALERA_INFO, + MB_SLAVE_INFO, + MB_INFO, + XTRABACKUP_BINLOG_INFO, + XTRABACKUP_GALERA_INFO, + XTRABACKUP_SLAVE_INFO, + XTRABACKUP_INFO, "ib_lru_dump", NULL}; datadir_iter_t *it = NULL; @@ -1894,8 +1898,12 @@ copy_back() while (datadir_iter_next(it, &node)) { const char *ext_list[] = {"backup-my.cnf", - "xtrabackup_binary", "xtrabackup_binlog_info", - "xtrabackup_checkpoints", ".qp", ".pmap", ".tmp", + "xtrabackup_binary", + MB_BINLOG_INFO, + MB_METADATA_FILENAME, + XTRABACKUP_BINLOG_INFO, + XTRABACKUP_METADATA_FILENAME, + ".qp", ".pmap", ".tmp", NULL}; const char *filename; char c_tmp; diff --git a/extra/mariabackup/backup_copy.h b/extra/mariabackup/backup_copy.h index 62b2b1bc232..3e1efa98177 100644 --- a/extra/mariabackup/backup_copy.h +++ b/extra/mariabackup/backup_copy.h @@ -6,11 +6,19 @@ #include <mysql.h> #include "datasink.h" -/* special files */ +/* special files, backward compatibility */ #define XTRABACKUP_SLAVE_INFO "xtrabackup_slave_info" #define XTRABACKUP_GALERA_INFO "xtrabackup_galera_info" #define XTRABACKUP_BINLOG_INFO "xtrabackup_binlog_info" #define XTRABACKUP_INFO "xtrabackup_info" +#define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints" + +/* special files */ +#define MB_SLAVE_INFO "mariadb_backup_slave_info" +#define MB_GALERA_INFO "mariadb_backup_galera_info" +#define MB_BINLOG_INFO "mariadb_backup_binlog_info" +#define MB_INFO "mariadb_backup_info" +#define MB_METADATA_FILENAME "mariadb_backup_checkpoints" extern bool binlog_locked; diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 69448586b33..b660e3112cd 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -1339,7 +1339,7 @@ write_slave_info(MYSQL *connection) } mysql_slave_position= strdup(comment.c_ptr()); - return backup_file_print_buf(XTRABACKUP_SLAVE_INFO, sql.ptr(), sql.length()); + return backup_file_print_buf(MB_SLAVE_INFO, sql.ptr(), sql.length()); } @@ -1362,7 +1362,7 @@ write_galera_info(MYSQL *connection) }; /* When backup locks are supported by the server, we should skip - creating xtrabackup_galera_info file on the backup stage, because + creating MB_GALERA_INFO file on the backup stage, because wsrep_local_state_uuid and wsrep_last_committed will be inconsistent without blocking commits. The state file will be created on the prepare stage using the WSREP recovery procedure. */ @@ -1379,7 +1379,7 @@ write_galera_info(MYSQL *connection) goto cleanup; } - result = backup_file_printf(XTRABACKUP_GALERA_INFO, + result = backup_file_printf(MB_GALERA_INFO, "%s:%s\n", state_uuid ? state_uuid : state_uuid55, last_committed ? last_committed : last_committed55); if (result) @@ -1513,7 +1513,7 @@ write_binlog_info(MYSQL *connection) read_mysql_variables(connection, "SHOW VARIABLES", vars, true); if (filename == NULL || position == NULL) { - /* Do not create xtrabackup_binlog_info if binary + /* Do not create MB_BINLOG_INFO if binary log is disabled */ result = true; goto cleanup; @@ -1529,14 +1529,14 @@ write_binlog_info(MYSQL *connection) "filename '%s', position '%s', " "GTID of the last change '%s'", filename, position, gtid) != -1); - result = backup_file_printf(XTRABACKUP_BINLOG_INFO, + result = backup_file_printf(MB_BINLOG_INFO, "%s\t%s\t%s\n", filename, position, gtid); } else { ut_a(asprintf(&mysql_binlog_position, "filename '%s', position '%s'", filename, position) != -1); - result = backup_file_printf(XTRABACKUP_BINLOG_INFO, + result = backup_file_printf(MB_BINLOG_INFO, "%s\t%s\n", filename, position); } @@ -1571,7 +1571,7 @@ operator<<(std::ostream& s, const escape_and_quote& eq) } /*********************************************************************//** -Writes xtrabackup_info file and if backup_history is enable creates +Writes MB_INFO file and if backup_history is enable creates mysql.mariabackup_history and writes a new history record to the table containing all the history info particular to the just completed backup. */ @@ -1647,7 +1647,7 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history, xb_stream_name[xtrabackup_stream_fmt], /* format */ xtrabackup_compress ? "compressed" : "N"); /* compressed */ if (buf_len < 0) { - msg("Error: cannot generate xtrabackup_info"); + msg("Error: cannot generate " MB_INFO); result = false; goto cleanup; } diff --git a/extra/mariabackup/backup_wsrep.h b/extra/mariabackup/backup_wsrep.h index 50a8a3a53e7..d992d925722 100644 --- a/extra/mariabackup/backup_wsrep.h +++ b/extra/mariabackup/backup_wsrep.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA #define BACKUP_WSREP_H /*********************************************************************** -Store Galera checkpoint info in the 'xtrabackup_galera_info' file, if that +Store Galera checkpoint info in the MB_GALERA_INFO file, if that information is present in the trx system header. Otherwise, do nothing. */ void xb_write_galera_info(bool incremental_prepare); diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc index b925b41552d..6c9a837b761 100644 --- a/extra/mariabackup/innobackupex.cc +++ b/extra/mariabackup/innobackupex.cc @@ -242,7 +242,7 @@ static struct my_option ibx_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"galera-info", OPT_GALERA_INFO, "This options creates the " - "xtrabackup_galera_info file which contains the local node state at " + MB_GALERA_INFO " file which contains the local node state at " "the time of the backup. Option should be used when performing the " "backup of MariaDB Galera Cluster. Has no effect when backup locks " "are used to create the backup.", @@ -252,10 +252,10 @@ static struct my_option ibx_long_options[] = {"slave-info", OPT_SLAVE_INFO, "This option is useful when backing " "up a replication slave server. It prints the binary log position " "and name of the master server. It also writes this information to " - "the \"xtrabackup_slave_info\" file as a \"CHANGE MASTER\" command. " + "the \"" MB_SLAVE_INFO "\" file as a \"CHANGE MASTER\" command. " "A new slave for this master can be set up by starting a slave server " "on this backup and issuing a \"CHANGE MASTER\" command with the " - "binary log position saved in the \"xtrabackup_slave_info\" file.", + "binary log position saved in the \"" MB_SLAVE_INFO "\" file.", (uchar *) &opt_ibx_slave_info, (uchar *) &opt_ibx_slave_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -518,7 +518,7 @@ static struct my_option ibx_long_options[] = {"extra-lsndir", OPT_EXTRA_LSNDIR, "This option specifies the " "directory in which to save an extra copy of the " - "\"xtrabackup_checkpoints\" file. The option accepts a string " + "\"" MB_METADATA_FILENAME "\" file. The option accepts a string " "argument.", (uchar*) &ibx_xtrabackup_extra_lsndir, (uchar*) &ibx_xtrabackup_extra_lsndir, diff --git a/extra/mariabackup/wsrep.cc b/extra/mariabackup/wsrep.cc index 1b93e9ed10e..45d44fb1fbb 100644 --- a/extra/mariabackup/wsrep.cc +++ b/extra/mariabackup/wsrep.cc @@ -53,9 +53,10 @@ permission notice: /*! Name of file where Galera info is stored on recovery */ #define XB_GALERA_INFO_FILENAME "xtrabackup_galera_info" +#define MB_GALERA_INFO_FILENAME "mariadb_backup_galera_info" /*********************************************************************** -Store Galera checkpoint info in the 'xtrabackup_galera_info' file, if that +Store Galera checkpoint info in the MB_GALERA_INFO_FILENAME file, if that information is present in the trx system header. Otherwise, do nothing. */ void xb_write_galera_info(bool incremental_prepare) @@ -70,7 +71,8 @@ xb_write_galera_info(bool incremental_prepare) /* Do not overwrite existing an existing file to be compatible with servers with older server versions */ if (!incremental_prepare && - my_stat(XB_GALERA_INFO_FILENAME, &statinfo, MYF(0)) != NULL) { + (my_stat(XB_GALERA_INFO_FILENAME, &statinfo, MYF(0)) != NULL || + my_stat(MB_GALERA_INFO_FILENAME, &statinfo, MYF(0)) != NULL)) { return; } @@ -89,11 +91,11 @@ xb_write_galera_info(bool incremental_prepare) return; } - fp = fopen(XB_GALERA_INFO_FILENAME, "w"); + fp = fopen(MB_GALERA_INFO_FILENAME, "w"); if (fp == NULL) { die( - "could not create " XB_GALERA_INFO_FILENAME + "could not create " MB_GALERA_INFO_FILENAME ", errno = %d\n", errno); exit(EXIT_FAILURE); @@ -107,7 +109,7 @@ xb_write_galera_info(bool incremental_prepare) if (fprintf(fp, "%s:%lld", uuid_str, (long long) seqno) < 0) { die( - "could not write to " XB_GALERA_INFO_FILENAME + "could not write to " MB_GALERA_INFO_FILENAME ", errno = %d\n", errno);; } diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 055e8ab85ec..724f2463ff6 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -120,7 +120,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA int sys_var_init(); /* === xtrabackup specific options === */ -char xtrabackup_real_target_dir[FN_REFLEN] = "./xtrabackup_backupfiles/"; +char xtrabackup_real_target_dir[FN_REFLEN] = "./mariadb_backup_files/"; char *xtrabackup_target_dir= xtrabackup_real_target_dir; static my_bool xtrabackup_version; static my_bool verbose; @@ -217,7 +217,6 @@ my_bool opt_extended_validation; my_bool opt_encrypted_backup; /* === metadata of backup === */ -#define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints" char metadata_type[30] = ""; /*[full-backuped|log-applied|incremental]*/ static lsn_t metadata_from_lsn; lsn_t metadata_to_lsn; @@ -1129,8 +1128,8 @@ struct my_option xb_client_options[]= { (G_PTR *) &xtrabackup_log_copy_interval, 0, GET_LONG, REQUIRED_ARG, 1000, 0, LONG_MAX, 0, 1, 0}, {"extra-lsndir", OPT_XTRA_EXTRA_LSNDIR, - "(for --backup): save an extra copy of the xtrabackup_checkpoints file " - "in this directory.", + "(for --backup): save an extra copy of the " MB_METADATA_FILENAME + " file in this directory.", (G_PTR *) &xtrabackup_extra_lsndir, (G_PTR *) &xtrabackup_extra_lsndir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"incremental-lsn", OPT_XTRA_INCREMENTAL, @@ -1244,7 +1243,7 @@ struct my_option xb_client_options[]= { {"galera-info", OPT_GALERA_INFO, "This options creates the " - "xtrabackup_galera_info file which contains the local node state at " + MB_GALERA_INFO " file which contains the local node state at " "the time of the backup. Option should be used when performing the " "backup of MariaDB Galera Cluster. Has no effect when backup locks " "are used to create the backup.", @@ -1255,10 +1254,10 @@ struct my_option xb_client_options[]= { "This option is useful when backing " "up a replication slave server. It prints the binary log position " "and name of the master server. It also writes this information to " - "the \"xtrabackup_slave_info\" file as a \"CHANGE MASTER\" command. " + "the \"" MB_SLAVE_INFO "\" file as a \"CHANGE MASTER\" command. " "A new slave for this master can be set up by starting a slave server " "on this backup and issuing a \"CHANGE MASTER\" command with the " - "binary log position saved in the \"xtrabackup_slave_info\" file.", + "binary log position saved in the \"" MB_SLAVE_INFO "\" file.", (uchar *) &opt_slave_info, (uchar *) &opt_slave_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -2373,6 +2372,37 @@ end: return(r); } + +/* +Read backup meta info. +@return TRUE on success, FALSE on failure. */ +static +my_bool +mb_read_metadata(const char *dir, const char *name) +{ + char filename[FN_REFLEN]; + snprintf(filename, sizeof(filename), "%s/%s", dir, name); + if (!xtrabackup_read_metadata(filename)) { + msg("mariabackup: error: failed to read metadata from " + "%s", filename); + return false; + } + return true; +} + + +/* +Read backup meta info from the given directory +with backward compatibility. */ +static +my_bool +mb_read_metadata_from_dir(const char *dir) +{ + return mb_read_metadata(dir, MB_METADATA_FILENAME) || + mb_read_metadata(dir, XTRABACKUP_METADATA_FILENAME); +} + + /*********************************************************************** Print backup meta info to a specified buffer. */ static @@ -2412,9 +2442,12 @@ xtrabackup_stream_metadata(ds_ctxt_t *ds_ctxt) mystat.st_size = len; mystat.st_mtime = my_time(0); - stream = ds_open(ds_ctxt, XTRABACKUP_METADATA_FILENAME, &mystat); + stream = ds_open(ds_ctxt, MB_METADATA_FILENAME, &mystat); + if (stream == NULL) { + stream = ds_open(ds_ctxt, XTRABACKUP_METADATA_FILENAME, &mystat); + } if (stream == NULL) { - msg("Error: cannot open output stream for %s", XTRABACKUP_METADATA_FILENAME); + msg("Error: cannot open output stream for %s", MB_METADATA_FILENAME); return(FALSE); } @@ -4451,14 +4484,14 @@ static bool xtrabackup_backup_low() char filename[FN_REFLEN]; sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, - XTRABACKUP_METADATA_FILENAME); + MB_METADATA_FILENAME); if (!xtrabackup_write_metadata(filename)) { msg("Error: failed to write metadata " "to '%s'.", filename); return false; } sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, - XTRABACKUP_INFO); + MB_INFO); if (!write_xtrabackup_info(mysql_connection, filename, false, false)) { msg("Error: failed to write info " "to '%s'.", filename); @@ -5823,7 +5856,6 @@ static ibool prepare_handle_del_files(const char *datadir, const char *db, const static bool xtrabackup_prepare_func(char** argv) { CorruptedPages corrupted_pages; - char metadata_path[FN_REFLEN]; /* cd to target-dir */ @@ -5874,12 +5906,7 @@ static bool xtrabackup_prepare_func(char** argv) /* read metadata of target */ - sprintf(metadata_path, "%s/%s", xtrabackup_target_dir, - XTRABACKUP_METADATA_FILENAME); - - if (!xtrabackup_read_metadata(metadata_path)) { - msg("Error: failed to read metadata from '%s'\n", - metadata_path); + if (!mb_read_metadata_from_dir(xtrabackup_target_dir)) { return(false); } @@ -6038,14 +6065,14 @@ error: metadata_last_lsn = incremental_last_lsn; } - sprintf(filename, "%s/%s", xtrabackup_target_dir, XTRABACKUP_METADATA_FILENAME); + sprintf(filename, "%s/%s", xtrabackup_target_dir, MB_METADATA_FILENAME); if (!xtrabackup_write_metadata(filename)) { msg("mariabackup: Error: failed to write metadata " "to '%s'", filename); ok = false; } else if (xtrabackup_extra_lsndir) { - sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, XTRABACKUP_METADATA_FILENAME); + sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, MB_METADATA_FILENAME); if (!xtrabackup_write_metadata(filename)) { msg("mariabackup: Error: failed to write " "metadata to '%s'", filename); @@ -6802,26 +6829,14 @@ static int main_low(char** argv) return(EXIT_FAILURE); } } else if (xtrabackup_backup && xtrabackup_incremental_basedir) { - char filename[FN_REFLEN]; - - sprintf(filename, "%s/%s", xtrabackup_incremental_basedir, XTRABACKUP_METADATA_FILENAME); - - if (!xtrabackup_read_metadata(filename)) { - msg("mariabackup: error: failed to read metadata from " - "%s", filename); + if (!mb_read_metadata_from_dir(xtrabackup_incremental_basedir)) { return(EXIT_FAILURE); } incremental_lsn = metadata_to_lsn; xtrabackup_incremental = xtrabackup_incremental_basedir; //dummy } else if (xtrabackup_prepare && xtrabackup_incremental_dir) { - char filename[FN_REFLEN]; - - sprintf(filename, "%s/%s", xtrabackup_incremental_dir, XTRABACKUP_METADATA_FILENAME); - - if (!xtrabackup_read_metadata(filename)) { - msg("mariabackup: error: failed to read metadata from " - "%s", filename); + if (!mb_read_metadata_from_dir(xtrabackup_incremental_dir)) { return(EXIT_FAILURE); } |