summaryrefslogtreecommitdiff
path: root/extra/mariabackup
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-09-23 10:25:34 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-09-23 10:25:34 +0300
commitc016ea660ede8b7ff75f8ca65f73e2958262263a (patch)
treec8bc8579c738792f0769ea70f49348dc1baf51b3 /extra/mariabackup
parent1bbe8c5e0f6823acd4780d7563e8c02f8b4c5a01 (diff)
parent2931fd2917cc130e34e5f3d9d6c571a2b013e49c (diff)
downloadmariadb-git-c016ea660ede8b7ff75f8ca65f73e2958262263a.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'extra/mariabackup')
-rw-r--r--extra/mariabackup/backup_copy.cc3
-rw-r--r--extra/mariabackup/backup_mysql.cc43
-rw-r--r--extra/mariabackup/backup_mysql.h3
-rw-r--r--extra/mariabackup/xtrabackup.cc2
4 files changed, 41 insertions, 10 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index 942e65dc40f..a31668a9642 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -1607,7 +1607,8 @@ bool backup_finish()
return(false);
}
- if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, opt_history != 0)) {
+ if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO,
+ opt_history != 0, true)) {
return(false);
}
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc
index 272496f2fef..236acce2483 100644
--- a/extra/mariabackup/backup_mysql.cc
+++ b/extra/mariabackup/backup_mysql.cc
@@ -1473,9 +1473,12 @@ PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the
table containing all the history info particular to the just completed
backup. */
bool
-write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
+write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
+ bool stream)
{
+ bool result = true;
+ FILE *fp = NULL;
char *uuid = NULL;
char *server_version = NULL;
char buf_start_time[100];
@@ -1501,7 +1504,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
|| xtrabackup_databases_exclude
);
- backup_file_printf(filename,
+ char *buf = NULL;
+ int buf_len = asprintf(&buf,
"uuid = %s\n"
"name = %s\n"
"tool_name = %s\n"
@@ -1513,8 +1517,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
"end_time = %s\n"
"lock_time = %d\n"
"binlog_pos = %s\n"
- "innodb_from_lsn = %llu\n"
- "innodb_to_lsn = %llu\n"
+ "innodb_from_lsn = " LSN_PF "\n"
+ "innodb_to_lsn = " LSN_PF "\n"
"partial = %s\n"
"incremental = %s\n"
"format = %s\n"
@@ -1531,12 +1535,34 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
(int)history_lock_time, /* lock_time */
mysql_binlog_position ?
mysql_binlog_position : "", /* binlog_pos */
- incremental_lsn, /* innodb_from_lsn */
- metadata_to_lsn, /* innodb_to_lsn */
+ incremental_lsn,
+ /* innodb_from_lsn */
+ metadata_to_lsn,
+ /* innodb_to_lsn */
is_partial? "Y" : "N",
xtrabackup_incremental ? "Y" : "N", /* incremental */
xb_stream_name[xtrabackup_stream_fmt], /* format */
xtrabackup_compress ? "compressed" : "N"); /* compressed */
+ if (buf_len < 0) {
+ msg("Error: cannot generate xtrabackup_info");
+ result = false;
+ goto cleanup;
+ }
+
+ if (stream) {
+ backup_file_printf(filename, "%s", buf);
+ } else {
+ fp = fopen(filename, "w");
+ if (!fp) {
+ msg("Error: cannot open %s", filename);
+ result = false;
+ goto cleanup;
+ }
+ if (fwrite(buf, buf_len, 1, fp) < 1) {
+ result = false;
+ goto cleanup;
+ }
+ }
if (!history) {
goto cleanup;
@@ -1598,8 +1624,11 @@ cleanup:
free(uuid);
free(server_version);
+ free(buf);
+ if (fp)
+ fclose(fp);
- return(true);
+ return(result);
}
extern const char *innodb_checksum_algorithm_names[];
diff --git a/extra/mariabackup/backup_mysql.h b/extra/mariabackup/backup_mysql.h
index e2c56f88a8c..b61fa2362c6 100644
--- a/extra/mariabackup/backup_mysql.h
+++ b/extra/mariabackup/backup_mysql.h
@@ -68,7 +68,8 @@ bool
write_binlog_info(MYSQL *connection);
bool
-write_xtrabackup_info(MYSQL *connection, const char * filename, bool history);
+write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
+ bool stream);
bool
write_backup_config_file();
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index a3bcff03e51..c14de6a3104 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -3966,7 +3966,7 @@ static bool xtrabackup_backup_low()
}
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir,
XTRABACKUP_INFO);
- if (!write_xtrabackup_info(mysql_connection, filename, false)) {
+ if (!write_xtrabackup_info(mysql_connection, filename, false, false)) {
msg("Error: failed to write info "
"to '%s'.", filename);
return false;