/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
* it should be used for next operations, and need to be closed
* at the end.
*/
-static bool open_bootstrap_file(JCR *jcr, struct bootstrap_info &info)
+static bool open_bootstrap_file(JCR *jcr, bootstrap_info &info)
{
FILE *bs;
UAContext *ua;
berrno be;
Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
jcr->RestoreBootstrap, be.bstrerror());
- set_jcr_job_status(jcr, JS_ErrorTerminated);
+ jcr->setJobStatus(JS_ErrorTerminated);
return false;
}
if (jcr->FDVersion < 2) {
return true;
}
- /* we are in init loop ? shoudn't fall here */
+ /* we are in init loop ? shoudn't fail here */
if (!*new_one) {
return true;
}
}
new_store = (STORE *)GetResWithName(R_STORAGE, new_one);
if (!new_store) {
- Jmsg(jcr, M_FATAL, 0,
+ Jmsg(jcr, M_WARNING, 0,
_("Could not get storage resource '%s'.\n"), new_one);
- set_jcr_job_status(jcr, JS_ErrorTerminated);
return false;
}
/* if Port and Hostname/IP are same, we are talking to the same
* Returns true if we need to change the storage, and it set the new
* Storage resource name in "storage" arg.
*/
-static bool check_for_new_storage(JCR *jcr, struct bootstrap_info &info)
+static bool check_for_new_storage(JCR *jcr, bootstrap_info &info)
{
UAContext *ua = info.ua;
parse_ua_args(ua);
* Send bootstrap file to Storage daemon section by section.
*/
static bool send_bootstrap_file(JCR *jcr, BSOCK *sock,
- struct bootstrap_info &info)
+ bootstrap_info &info)
{
boffset_t pos;
const char *bootstrap = "bootstrap\n";
return true;
}
+#define MAX_TRIES 6 * 360 /* 6 hours */
+
/**
* Change the read storage resource for the current job.
*/
-static void select_rstore(JCR *jcr, struct bootstrap_info &info)
+static bool select_rstore(JCR *jcr, bootstrap_info &info)
{
USTORE ustore;
+ int i;
+
if (!strcmp(jcr->rstore->name(), info.storage)) {
- return;
+ return true; /* same SD nothing to change */
}
if (!(ustore.store = (STORE *)GetResWithName(R_STORAGE,info.storage))) {
Jmsg(jcr, M_FATAL, 0,
_("Could not get storage resource '%s'.\n"), info.storage);
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- return;
+ jcr->setJobStatus(JS_ErrorTerminated);
+ return false;
}
+ /*
+ * What does this do??????????? KES
+ */
if (jcr->store_bsock) {
jcr->store_bsock->destroy();
jcr->store_bsock = NULL;
}
+ /*
+ * release current read storage and get a new one
+ */
+ dec_read_store(jcr);
free_rstorage(jcr);
set_rstorage(jcr, &ustore);
+ jcr->setJobStatus(JS_WaitSD);
+ /*
+ * Wait for up to 6 hours to increment read stoage counter
+ */
+ for (i=0; i < MAX_TRIES; i++) {
+ /* try to get read storage counter incremented */
+ if (inc_read_store(jcr)) {
+ jcr->setJobStatus(JS_Running);
+ return true;
+ }
+ bmicrosleep(10, 0); /* sleep 10 secs */
+ if (job_canceled(jcr)) {
+ free_rstorage(jcr);
+ return false;
+ }
+ }
+ /* Failed to inc_read_store() */
+ free_rstorage(jcr);
+ Jmsg(jcr, M_FATAL, 0,
+ _("Could not acquire read storage lock for \"%s\""), info.storage);
+ return false;
}
/*
- * Clean the struct bootstrap_info struct
+ * Clean the bootstrap_info struct
*/
-static void close_bootstrap_file(struct bootstrap_info &info)
+static void close_bootstrap_file(bootstrap_info &info)
{
if (info.bs) {
fclose(info.bs);
BSOCK *fd = NULL;
BSOCK *sd;
bool first_time = true;
- struct bootstrap_info info;
+ bootstrap_info info;
POOL_MEM restore_cmd(PM_MESSAGE);
bool ret = false;
/* Read the bootstrap file */
while (!feof(info.bs)) {
- select_rstore(jcr, info);
+ if (!select_rstore(jcr, info)) {
+ goto bail_out;
+ }
/**
* Open a message channel connection with the Storage
*
*/
Dmsg0(10, "Open connection with storage daemon\n");
- set_jcr_job_status(jcr, JS_WaitSD);
+ jcr->setJobStatus(JS_WaitSD);
/*
* Start conversation with Storage daemon
*/
/*
* Start conversation with File daemon
*/
- set_jcr_job_status(jcr, JS_WaitFD);
+ jcr->setJobStatus(JS_WaitFD);
jcr->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */
if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) {
goto bail_out;
fd = jcr->file_bsock;
}
- set_jcr_job_status(jcr, JS_WaitSD);
+ jcr->setJobStatus(JS_Running);
/*
* Send the bootstrap file -- what Volumes/files to restore
jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
- Jmsg(jcr, msg_type, 0, _("%s %s %s (%s): %s\n"
+ Jmsg(jcr, msg_type, 0, _("%s %s %s (%s):\n"
" Build OS: %s %s %s\n"
" JobId: %d\n"
" Job: %s\n"
" FD termination status: %s\n"
" SD termination status: %s\n"
" Termination: %s\n\n"),
- BACULA, my_name, VERSION, LSMDATE, edt,
+ BACULA, my_name, VERSION, LSMDATE,
HOST_OS, DISTNAME, DISTVER,
jcr->jr.JobId,
jcr->jr.Job,