Plugin *plugin;
int i = 0;
- if (!plugin_list || !jcr || !jcr->plugin_ctx_list || job_canceled(jcr)) {
+ if (!plugin_list || !jcr || !jcr->plugin_ctx_list || jcr->is_job_canceled()) {
return; /* Return if no plugins loaded */
}
int rc = bRC_OK;
int i = 0;
- if (!plugin_list || !jcr || !jcr->plugin_ctx_list || job_canceled(jcr)) {
+ if (!plugin_list || !jcr || !jcr->plugin_ctx_list || jcr->is_job_canceled()) {
return false; /* Return if no plugins loaded */
}
POOL_MEM fname(PM_FNAME);
POOL_MEM link(PM_FNAME);
- if (!plugin_list || !jcr->plugin_ctx_list || job_canceled(jcr)) {
+ if (!plugin_list || !jcr->plugin_ctx_list || jcr->is_job_canceled()) {
Jmsg1(jcr, M_FATAL, 0, "Command plugin \"%s\" not loaded.\n", cmd);
return 1; /* Return if no plugins loaded */
}
goto bail_out;
}
/* Loop getting filenames to backup then saving them */
- while (!job_canceled(jcr)) {
+ while (!jcr->is_job_canceled()) {
memset(&sp, 0, sizeof(sp));
sp.pkt_size = sizeof(sp);
sp.pkt_end = sizeof(sp);
sp.cmd = cmd;
Dmsg3(dbglvl, "startBackup st_size=%p st_blocks=%p sp=%p\n", &sp.statp.st_size, &sp.statp.st_blocks,
&sp);
- /* Get the file save parameters */
+ /* Get the file save parameters. I.e. the stat pkt ... */
if (plug_func(plugin)->startBackupFile(jcr->plugin_ctx, &sp) != bRC_OK) {
goto bail_out;
}
- if (sp.type == 0 || sp.fname == NULL) {
- Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\" returned bad startBackupFile packet.\n"),
+ if (sp.type == 0) {
+ Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\": no type in startBackupFile packet.\n"),
cmd);
goto bail_out;
}
* Copy fname and link because save_file() zaps them. This
* avoids zaping the plugin's strings.
*/
- pm_strcpy(fname, sp.fname);
- pm_strcpy(link, sp.link);
- ff_pkt->fname = fname.c_str();
- ff_pkt->link = link.c_str();
ff_pkt->type = sp.type;
+ if (sp.type == FT_RESTORE_FIRST) {
+ if (!sp.object_name) {
+ Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\": no object_name in startBackupFile packet.\n"),
+ cmd);
+ goto bail_out;
+ }
+ ff_pkt->fname = cmd; /* full plugin string */
+ ff_pkt->object_name = sp.object_name;
+ ff_pkt->object_index = sp.index; /* restore object index */
+ ff_pkt->object_compression = 0; /* no compression for now */
+ ff_pkt->object = sp.object;
+ ff_pkt->object_len = sp.object_len;
+ } else {
+ if (!sp.fname) {
+ Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\": no fname in startBackupFile packet.\n"),
+ cmd);
+ goto bail_out;
+ }
+ pm_strcpy(fname, sp.fname);
+ pm_strcpy(link, sp.link);
+ ff_pkt->fname = fname.c_str();
+ ff_pkt->link = link.c_str();
+ }
+
memcpy(&ff_pkt->statp, &sp.statp, sizeof(ff_pkt->statp));
- Dmsg1(dbglvl, "Save_file: file=%s\n", fname.c_str());
+ Dmsg2(dbglvl, "startBackup returned type=%d, fname=%s\n", sp.type, sp.fname);
+ if (sp.object) {
+ Dmsg2(dbglvl, "index=%d object=%s\n", sp.index, sp.object);
+ }
+ /* Call Bacula core code to backup the plugin's file */
save_file(jcr, ff_pkt, true);
bRC rc = plug_func(plugin)->endBackupFile(jcr->plugin_ctx);
if (rc == bRC_More || rc == bRC_OK) {
Jmsg0(jcr, M_FATAL, 0, _("Plugin save packet not found.\n"));
return false;
}
- if (job_canceled(jcr)) {
+ if (jcr->is_job_canceled()) {
return false;
}
sd->bstrerror());
return false;
}
- Dmsg1(50, "send: %s\n", sd->msg);
+ Dmsg1(50, "send plugin name hdr: %s\n", sd->msg);
if (start) {
/* Send data -- not much */
sd->bstrerror());
return false;
}
- Dmsg1(dbglvl, "send: %s\n", sd->msg);
+ Dmsg1(dbglvl, "send plugin start/end: %s\n", sd->msg);
sd->signal(BNET_EOD); /* indicate end of plugin name data */
return true;
}
int flags;
int rc;
- if (!plugin || !plugin_ctx || !set_cmd_plugin(bfd, jcr) || job_canceled(jcr)) {
+ if (!plugin || !plugin_ctx || !set_cmd_plugin(bfd, jcr) || jcr->is_job_canceled()) {
return CF_ERROR;
}
+
rp.pkt_size = sizeof(rp);
rp.pkt_end = sizeof(rp);
rp.stream = attr->stream;
rp.RegexWhere = jcr->RegexWhere;
rp.replace = jcr->replace;
rp.create_status = CF_ERROR;
- Dmsg1(dbglvl, "call plugin createFile=%s\n", rp.ofname);
+ Dmsg4(dbglvl, "call plugin createFile stream=%d type=%d LinkFI=%d File=%s\n",
+ rp.stream, rp.type, rp.LinkFI, rp.ofname);
+ if (rp.attrEx) {
+ Dmsg1(dbglvl, "attrEx=\"%s\"\n", rp.attrEx);
+ }
rc = plug_func(plugin)->createFile(plugin_ctx, &rp);
if (rc != bRC_OK) {
Qmsg2(jcr, M_ERROR, 0, _("Plugin createFile call failed. Stat=%d file=%s\n"),
Dmsg0(dbglvl, "plugin list is NULL\n");
return;
}
- if (job_canceled(jcr)) {
+ if (jcr->is_job_canceled() || jcr->JobId == 0) {
return;
}
{
JCR *jcr;
bacula_ctx *bctx;
- if (ctx) {
+ if (!ctx) {
return bRC_Error;
}
if (!file) {