Skip to content

Commit

Permalink
NDMP_NATIVE: cleanup
Browse files Browse the repository at this point in the history
Assign database schema version 2171 to Bareos >= 17.2.3.
Director Storage resource:
  * Renamed the ChangerDevice directive to NdmpChangerDevice (for clarification)
  * Removed the TapeDevice directive. Use Device instead.
Remove some unused code.
  • Loading branch information
joergsteffens committed Sep 1, 2017
1 parent 4947a83 commit f310a4c
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 303 deletions.
1 change: 1 addition & 0 deletions src/cats/ddl/versions.map.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
14.2.0=2003
15.2.0=2004
17.2.2=2170
17.2.3=2171

default=@BDB_VERSION@
5 changes: 0 additions & 5 deletions src/cats/postgresql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,6 @@ bool B_DB_POSTGRESQL::sql_batch_start(JCR *jcr)

Dmsg0(500, "sql_batch_start started\n");

// Jmsg(jcr, M_INFO, 0, "sql_batch_start: m_db_handle is :%p, jcr is %p\n", (void *) m_db_handle , (void *) jcr);

if (!sql_query_without_handler("CREATE TEMPORARY TABLE batch ("
"FileIndex int,"
"JobId int,"
Expand Down Expand Up @@ -1099,8 +1097,6 @@ bool B_DB_POSTGRESQL::sql_batch_end(JCR *jcr, const char *error)

Dmsg0(500, "sql_batch_end started\n");

// Jmsg(jcr, M_INFO, 0, "sql_batch_end: m_db_handle is :%p, jcr is %p\n", (void *) m_db_handle , (void *) jcr);

do {
res = PQputCopyEnd(m_db_handle, error);
} while (res == 0 && --count > 0);
Expand Down Expand Up @@ -1177,7 +1173,6 @@ bool B_DB_POSTGRESQL::sql_batch_insert(JCR *jcr, ATTR_DBR *ar)
}

Dmsg0(500, "sql_batch_insert finishing\n");
// Jmsg(jcr, M_INFO, 0, "sql_batch_insert: m_db_handle is :%p, jcr is %p\n", (void *) m_db_handle , (void *) jcr);

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/cats/protos.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
Copyright (C) 2011-2017 Planets Communications B.V.
Copyright (C) 2013-2016 Bareos GmbH & Co. KG
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2017 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down
21 changes: 8 additions & 13 deletions src/dird/dird_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
* for the resource records.
*
*/
/*
* Kern Sibbald, January MM
*/

#define NEED_JANSSON_NAMESPACE 1
#include "bareos.h"
Expand Down Expand Up @@ -291,10 +288,12 @@ static RES_ITEM store_items[] = {
{ "PairedStorage", CFG_TYPE_RES, ITEM(res_store.paired_storage), R_STORAGE, 0, NULL, NULL, NULL },
{ "MaximumBandwidthPerJob", CFG_TYPE_SPEED, ITEM(res_store.max_bandwidth), 0, 0, NULL, NULL, NULL },
{ "CollectStatistics", CFG_TYPE_BOOL, ITEM(res_store.collectstats), 0, CFG_ITEM_DEFAULT, "false", NULL, NULL },
{ "ChangerDevice", CFG_TYPE_STRNAME, ITEM(res_store.changer_device), 0, 0, NULL, "16.2.4-",
"Allows direct control of a Storage Daemon Auto Changer device by the Director. Only used in specific NDMP environments." },
{ "TapeDevice", CFG_TYPE_ALIST_STR, ITEM(res_store.tape_devices), 0, 0, NULL, "16.2.4-",
"Allows direct control of Storage Daemon Tape devices by the Director. Only used in specific NDMP environments." },
{ "NdmpChangerDevice", CFG_TYPE_STRNAME, ITEM(res_store.ndmp_changer_device), 0, 0, NULL, "16.2.4-",
"Allows direct control of a Storage Daemon Auto Changer device by the Director. Only used in NDMP_NATIVE environments." },
// TapeDevice has never been used in production and intended for NDMP_NATIVE only.
// Instead of TapeDevice, the required Devices should be configured using the Device directive.
//{ "TapeDevice", CFG_TYPE_ALIST_STR, ITEM(res_store.tape_devices), 0, CFG_ITEM_ALIAS | CFG_ITEM_DEPRECATED, NULL, "16.2.4-17.2.2",
// "Allows direct control of Storage Daemon Tape devices by the Director. Only used in NDMP_NATIVE environments." },
TLS_CONFIG(res_store)
{ NULL, 0, { 0 }, 0, 0, NULL, NULL, NULL }
};
Expand Down Expand Up @@ -2599,11 +2598,8 @@ void free_resource(RES *sres, int type)
if (res->res_store.media_type) {
free(res->res_store.media_type);
}
if (res->res_store.changer_device) {
free(res->res_store.changer_device);
}
if (res->res_store.tape_devices) {
delete res->res_store.tape_devices;
if (res->res_store.ndmp_changer_device) {
free(res->res_store.ndmp_changer_device);
}
if (res->res_store.device) {
delete res->res_store.device;
Expand Down Expand Up @@ -2845,7 +2841,6 @@ static bool update_resource_pointer(int type, RES_ITEM *items)
} else {
int status;

res->res_store.tape_devices = res_all.res_store.tape_devices;
res->res_store.paired_storage = res_all.res_store.paired_storage;
res->res_store.tls.allowed_cns = res_all.res_store.tls.allowed_cns;

Expand Down
3 changes: 1 addition & 2 deletions src/dird/dird_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ class STORERES : public BRSRES {
char *username; /* Username to use for authentication if protocol supports it */
s_password password;
char *media_type; /**< Media Type provided by this Storage */
char *changer_device; /**< If DIR controls storage directly changer device used */
alist *tape_devices; /**< If DIR controls storage directly tape devices in storage */
char *ndmp_changer_device; /**< If DIR controls storage directly (NDMP_NATIVE) changer device used */
alist *device; /**< Alternate devices for this Storage */
int32_t MaxConcurrentJobs; /**< Maximum concurrent jobs */
int32_t MaxConcurrentReadJobs; /**< Maximum concurrent jobs reading */
Expand Down
77 changes: 0 additions & 77 deletions src/dird/ndmp_dma_backup_NDMP_BAREOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,78 +171,6 @@ bool do_ndmp_backup_init(JCR *jcr)
}


/*
* Cleanup a NDMP backup session.
*/
void ndmp_backup_cleanup(JCR *jcr, int TermCode)
{
const char *term_msg;
char term_code[100];
int msg_type = M_INFO;
CLIENT_DBR cr;

Dmsg2(100, "Enter ndmp_backup_cleanup %d %c\n", TermCode, TermCode);
memset(&cr, 0, sizeof(cr));

if (jcr->is_JobStatus(JS_Terminated) &&
(jcr->JobErrors || jcr->SDErrors || jcr->JobWarnings)) {
TermCode = JS_Warnings;
}

update_job_end(jcr, TermCode);

if (!jcr->db->get_job_record(jcr, &jcr->jr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"),
jcr->db->strerror());
jcr->setJobStatus(JS_ErrorTerminated);
}

bstrncpy(cr.Name, jcr->res.client->name(), sizeof(cr.Name));
if (!jcr->db->get_client_record(jcr, &cr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"),
jcr->db->strerror());
}

update_bootstrap_file(jcr);

switch (jcr->JobStatus) {
case JS_Terminated:
term_msg = _("Backup OK");
break;
case JS_Warnings:
term_msg = _("Backup OK -- with warnings");
break;
case JS_FatalError:
case JS_ErrorTerminated:
term_msg = _("*** Backup Error ***");
msg_type = M_ERROR; /* Generate error message */
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
if (jcr->SD_msg_chan_started) {
pthread_cancel(jcr->SD_msg_chan);
}
}
break;
case JS_Canceled:
term_msg = _("Backup Canceled");
if (jcr->store_bsock) {
jcr->store_bsock->signal(BNET_TERMINATE);
if (jcr->SD_msg_chan_started) {
pthread_cancel(jcr->SD_msg_chan);
}
}
break;
default:
term_msg = term_code;
sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
break;
}

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

Dmsg0(100, "Leave ndmp_backup_cleanup\n");
}

/**
* Run a NDMP backup session.
*/
Expand Down Expand Up @@ -617,9 +545,4 @@ bool do_ndmp_backup(JCR *jcr)
return false;
}

void ndmp_backup_cleanup(JCR *jcr, int TermCode)
{
Jmsg(jcr, M_FATAL, 0, _("NDMP protocol not supported\n"));
}

#endif /* HAVE_NDMP */
57 changes: 8 additions & 49 deletions src/dird/ndmp_dma_backup_NDMP_NATIVE.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
STORERES *store = jcr->res.wstore;
int drive = 0;

int index = 1;


int NUMBER_OF_VOLS=4;
/*
* Initialize the ndmp backup job. We build the generic job only once
* and reuse the job definition for each separate sub-backup we perform as
Expand All @@ -227,7 +223,7 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
* device in the form NAME[,[CNUM,]SID[,LUN]
*/
ndmp_job.robot_target = (struct ndmscsi_target *)actuallymalloc(sizeof(struct ndmscsi_target));
if (ndmscsi_target_from_str(ndmp_job.robot_target, store->changer_device) != 0) {
if (ndmscsi_target_from_str(ndmp_job.robot_target, store->ndmp_changer_device) != 0) {
actuallyfree(ndmp_job.robot_target);
Dmsg0(100,"ndmp_send_label_request: no robot to use\n");
return retval;
Expand All @@ -242,7 +238,6 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
/*
* Set the remote tape drive to use.
*/

ndmp_job.tape_device = lookup_ndmp_drive(store, drive);
ndmp_job.record_size = jcr->res.client->ndmp_blocksize;

Expand Down Expand Up @@ -329,10 +324,6 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
/* register the callbacks */
ndmca_media_register_callbacks (&ndmp_sess, &media_callbacks);


/* configure first tape */
//ndmp_load_next(&ndmp_sess);

/*
* The full ndmp archive has a virtual filename, we need it to hardlink the individual
* file records to it. So we allocate it here once so its available during the whole
Expand All @@ -349,13 +340,10 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
}
nis->virtual_filename = bstrdup(virtual_filename.c_str());

//ndma_job_auto_adjust(&ndmp_sess.control_acb->job);

/* disabled because of "missing media entry" error
if (!ndmp_validate_job(jcr, &ndmp_sess.control_acb->job)) {
goto cleanup;
}
*/
// FIXME: disabled because of "missing media entry" error
//if (!ndmp_validate_job(jcr, &ndmp_sess.control_acb->job)) {
// goto cleanup;
//}

/*
* Commission the session for a run.
Expand Down Expand Up @@ -404,15 +392,6 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
ndma_destroy_env_list(&ndmp_sess.control_acb->job.result_env_tab);
ndma_destroy_nlist(&ndmp_sess.control_acb->job.nlist_tab);

/*
* Release any tape device name allocated.
*/
/*
if (ndmp_sess.control_acb->job.tape_device) {
free(ndmp_sess.control_acb->job.tape_device);
ndmp_sess.control_acb->job.tape_device = NULL;
}
*/
/*
* Destroy the session.
*/
Expand All @@ -437,16 +416,6 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
status = JS_Terminated;
retval = true;

/*
* Tell the storage daemon we are done.
*/
#if 0
if (jcr->store_bsock) {
jcr->store_bsock->fsend("finish");
wait_for_storage_daemon_termination(jcr);
db_write_batch_file_records(jcr); /* used by bulk batch file insert */
}
#endif
/*
* If we do incremental backups it can happen that the backup is empty if
* nothing changed but we always write a filestream. So we use the counter
Expand Down Expand Up @@ -494,19 +463,13 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
status = JS_ErrorTerminated;
jcr->setJobStatus(JS_ErrorTerminated);

if (jcr->store_bsock) {
cancel_storage_daemon_job(jcr);
wait_for_storage_daemon_termination(jcr);
}

ok_out:
if (nis) {
if (nis->virtual_filename) {
free(nis->virtual_filename);
}
free(nis);
}
free_paired_storage(jcr);

if (status == JS_Terminated) {
ndmp_backup_cleanup(jcr, status);
Expand Down Expand Up @@ -586,8 +549,9 @@ static inline bool extract_post_backup_stats_ndmp_native(JCR *jcr,
return false;
}

//Jmsg(jcr, M_INFO, 0, _("extract_post_backup_stats\n"));

/*
* extract_post_backup_stats
*/
for (media = sess->control_acb->job.media_tab.head; media; media = media->next) {

/*
Expand Down Expand Up @@ -677,9 +641,4 @@ bool do_ndmp_backup_ndmp_native(JCR *jcr)
return false;
}

void ndmp_backup_cleanup_ndmp_native(JCR *jcr, int TermCode)
{
Jmsg(jcr, M_FATAL, 0, _("NDMP protocol not supported\n"));
}

#endif /* HAVE_NDMP */
Loading

0 comments on commit f310a4c

Please sign in to comment.