Skip to content

Commit

Permalink
Fix backup summary.
Browse files Browse the repository at this point in the history
Always lookup the media record of the last used volume after calling
db_get_job_volume_names() so we always print the right info and not
lookup the media record based on the current content of jcr->VolumeName
which works only for normal backups but not for virtual fulls as there
it will have the name of the last volume that was read for creating the
virtual full. Looking at the migration code it also does a lookup
of the last volume name returned by db_get_job_volume_names() there.

Fixes #211: Wrong data/output/calculation in log of "Last Volume Bytes"
            and "Volume Session Time" when doing Virtual Full Backups
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 75930b2 commit 5ad3aa8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 33 deletions.
35 changes: 22 additions & 13 deletions src/dird/backup.c
Expand Up @@ -690,7 +690,6 @@ void native_backup_cleanup(JCR *jcr, int TermCode)
const char *term_msg;
char term_code[100];
int msg_type = M_INFO;
MEDIA_DBR mr;
CLIENT_DBR cr;

Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode);
Expand Down Expand Up @@ -722,13 +721,6 @@ void native_backup_cleanup(JCR *jcr, int TermCode)
db_strerror(jcr->db));
}

bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName));
if (!db_get_media_record(jcr, jcr->db, &mr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
mr.VolumeName, db_strerror(jcr->db));
jcr->setJobStatus(JS_ErrorTerminated);
}

update_bootstrap_file(jcr);

switch (jcr->JobStatus) {
Expand Down Expand Up @@ -771,7 +763,7 @@ void native_backup_cleanup(JCR *jcr, int TermCode)
break;
}

generate_backup_summary(jcr, &mr, &cr, msg_type, term_msg);
generate_backup_summary(jcr, &cr, msg_type, term_msg);

Dmsg0(100, "Leave backup_cleanup()\n");
}
Expand Down Expand Up @@ -854,15 +846,15 @@ void update_bootstrap_file(JCR *jcr)
* - native_vbackup_cleanup e.g. virtual backups
* - ndmp_backup_cleanup e.g. NDMP backups
*/
void generate_backup_summary(JCR *jcr, MEDIA_DBR *mr, CLIENT_DBR *cr,
int msg_type, const char *term_msg)
void generate_backup_summary(JCR *jcr, CLIENT_DBR *cr, int msg_type, const char *term_msg)
{
char sdt[50], edt[50], schedt[50], gdt[50];
char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], compress[50];
char ec6[30], ec7[30], ec8[30], elapsed[50];
char fd_term_msg[100], sd_term_msg[100];
double kbps, compression;
utime_t RunTime;
MEDIA_DBR mr;
POOL_MEM level_info,
statistics,
quota_info,
Expand Down Expand Up @@ -898,6 +890,23 @@ void generate_backup_summary(JCR *jcr, MEDIA_DBR *mr, CLIENT_DBR *cr,
jcr->VolumeName[0] = 0; /* none */
}

if (jcr->VolumeName[0]) {
/*
* Find last volume name. Multiple vols are separated by |
*/
char *p = strrchr(jcr->VolumeName, '|');
if (p) {
p++; /* skip | */
} else {
p = jcr->VolumeName; /* no |, take full name */
}
bstrncpy(mr.VolumeName, p, sizeof(mr.VolumeName));
if (!db_get_media_record(jcr, jcr->db, &mr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
mr.VolumeName, db_strerror(jcr->db));
}
}

if (jcr->ReadBytes == 0) {
bstrncpy(compress, "None", sizeof(compress));
} else {
Expand Down Expand Up @@ -1084,8 +1093,8 @@ void generate_backup_summary(JCR *jcr, MEDIA_DBR *mr, CLIENT_DBR *cr,
jcr->VolumeName,
jcr->VolSessionId,
jcr->VolSessionTime,
edit_uint64_with_commas(mr->VolBytes, ec7),
edit_uint64_with_suffix(mr->VolBytes, ec8),
edit_uint64_with_commas(mr.VolBytes, ec7),
edit_uint64_with_suffix(mr.VolBytes, ec8),
daemon_status.c_str(),
term_msg);
}
10 changes: 1 addition & 9 deletions src/dird/ndmp_dma.c
Expand Up @@ -1480,7 +1480,6 @@ void ndmp_backup_cleanup(JCR *jcr, int TermCode)
const char *term_msg;
char term_code[100];
int msg_type = M_INFO;
MEDIA_DBR mr;
CLIENT_DBR cr;

Dmsg2(100, "Enter ndmp_backup_cleanup %d %c\n", TermCode, TermCode);
Expand Down Expand Up @@ -1512,13 +1511,6 @@ void ndmp_backup_cleanup(JCR *jcr, int TermCode)
db_strerror(jcr->db));
}

bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName));
if (!db_get_media_record(jcr, jcr->db, &mr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
mr.VolumeName, db_strerror(jcr->db));
jcr->setJobStatus(JS_ErrorTerminated);
}

update_bootstrap_file(jcr);

switch (jcr->JobStatus) {
Expand Down Expand Up @@ -1558,7 +1550,7 @@ void ndmp_backup_cleanup(JCR *jcr, int TermCode)
break;
}

generate_backup_summary(jcr, &mr, &cr, msg_type, term_msg);
generate_backup_summary(jcr, &cr, msg_type, term_msg);

Dmsg0(100, "Leave ndmp_backup_cleanup\n");
}
Expand Down
4 changes: 2 additions & 2 deletions src/dird/protos.h
Expand Up @@ -53,8 +53,8 @@ bool do_native_backup(JCR *jcr);
void native_backup_cleanup(JCR *jcr, int TermCode);
void update_bootstrap_file(JCR *jcr);
bool send_accurate_current_files(JCR *jcr);
void generate_backup_summary(JCR *jcr, MEDIA_DBR *mr, CLIENT_DBR *cr,
int msg_type, const char *term_msg);
void generate_backup_summary(JCR *jcr, CLIENT_DBR *cr, int msg_type,
const char *term_msg);

/* vbackup.c */
bool do_native_vbackup_init(JCR *jcr);
Expand Down
10 changes: 1 addition & 9 deletions src/dird/vbackup.c
Expand Up @@ -294,7 +294,6 @@ void native_vbackup_cleanup(JCR *jcr, int TermCode)
char term_code[100];
const char *term_msg;
int msg_type = M_INFO;
MEDIA_DBR mr;
CLIENT_DBR cr;
POOL_MEM query(PM_MESSAGE);

Expand Down Expand Up @@ -328,13 +327,6 @@ void native_vbackup_cleanup(JCR *jcr, int TermCode)
db_strerror(jcr->db));
}

bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName));
if (!db_get_media_record(jcr, jcr->db, &mr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
mr.VolumeName, db_strerror(jcr->db));
jcr->setJobStatus(JS_ErrorTerminated);
}

update_bootstrap_file(jcr);

switch (jcr->JobStatus) {
Expand Down Expand Up @@ -371,7 +363,7 @@ void native_vbackup_cleanup(JCR *jcr, int TermCode)
break;
}

generate_backup_summary(jcr, &mr, &cr, msg_type, term_msg);
generate_backup_summary(jcr, &cr, msg_type, term_msg);

Dmsg0(100, "Leave vbackup_cleanup()\n");
}
Expand Down

0 comments on commit 5ad3aa8

Please sign in to comment.