X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fmac.c;h=f2435e7838a7b9f7a3f10eff7b21407d8b2d036f;hb=36b40d5c7f3ff90565ab73ac75f0dc4f6660ff37;hp=a36f6a37338dec08edb5cc75dd2fa1d6f2483317;hpb=c37638750b04e222c9436d70c55d28193c58a86f;p=bacula%2Fbacula diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index a36f6a3733..f2435e7838 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -1,22 +1,14 @@ -/* - * SD -- mac.c -- responsible for doing - * migration, archive, and copy jobs. - * - * Kern Sibbald, January MMVI - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2006-2006 Free Software Foundation Europe e.V. + Copyright (C) 2006-2008 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 - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. + License as published by the Free Software Foundation and included + in the file LICENSE. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,11 +20,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Bacula® is a registered trademark of John Walker. + Bacula® is a registered trademark of Kern Sibbald. The licensor of Bacula is the Free Software Foundation Europe (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * SD -- mac.c -- responsible for doing + * migration, archive, copy, and virtual backup jobs. + * + * Kern Sibbald, January MMVI + * + * Version $Id$ + */ #include "bacula.h" #include "stored.h" @@ -57,7 +57,7 @@ bool do_mac(JCR *jcr) char ec1[50]; DEVICE *dev; - switch(jcr->JobType) { + switch(jcr->get_JobType()) { case JT_MIGRATE: Type = "Migration"; break; @@ -67,6 +67,9 @@ bool do_mac(JCR *jcr) case JT_COPY: Type = "Copy"; break; + case JT_BACKUP: + Type = "Virtual Backup"; + break; default: Type = "Unknown"; break; @@ -83,12 +86,12 @@ bool do_mac(JCR *jcr) create_restore_volume_list(jcr); - if (jcr->NumVolumes == 0) { + if (jcr->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for %s.\n"), Type); goto bail_out; } - Dmsg3(200, "Found %d volumes names for %s. First=%s\n", jcr->NumVolumes, + Dmsg3(200, "Found %d volumes names for %s. First=%s\n", jcr->NumReadVolumes, jcr->VolList->VolumeName, Type); /* Ready devices for reading and writing */ @@ -100,12 +103,15 @@ bool do_mac(JCR *jcr) Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->dcr->dev->file, jcr->dcr->dev->block_num); - set_jcr_job_status(jcr, JS_Running); dir_send_job_status(jcr); + begin_data_spool(jcr->dcr); + begin_attribute_spool(jcr); + jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0; jcr->run_time = time(NULL); + set_start_vol_position(jcr->dcr); ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume); goto ok_out; @@ -127,12 +133,24 @@ ok_out: Dmsg2(200, "Flush block to device pos %u:%u\n", dev->file, dev->block_num); } + if (!ok) { + discard_data_spool(jcr->dcr); + } else { + /* Note: if commit is OK, the device will remain locked */ + commit_data_spool(jcr->dcr); + } if (ok && dev->is_dvd()) { ok = dvd_close_job(jcr->dcr); /* do DVD cleanup if any */ } /* Release the device -- and send final Vol info to DIR */ release_device(jcr->dcr); + + if (!ok || job_canceled(jcr)) { + discard_attribute_spool(jcr); + } else { + commit_attribute_spool(jcr); + } } if (jcr->read_dcr) { @@ -143,13 +161,6 @@ ok_out: free_restore_volume_list(jcr); - - if (!ok || job_canceled(jcr)) { - discard_attribute_spool(jcr); - } else { - commit_attribute_spool(jcr); - } - dir_send_job_status(jcr); /* update director */ @@ -160,11 +171,11 @@ ok_out: set_jcr_job_status(jcr, JS_Terminated); } generate_daemon_event(jcr, "JobEnd"); - bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, + dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->JobBytes, ec1)); Dmsg4(200, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, ec1); - bnet_sig(dir, BNET_EOD); /* send EOD to Director daemon */ + dir->signal(BNET_EOD); /* send EOD to Director daemon */ return ok; } @@ -232,17 +243,18 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_UNIX_ATTRIBUTES_EX || crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) { if (!jcr->no_attributes) { + BSOCK *dir = jcr->dir_bsock; if (are_attributes_spooled(jcr)) { - jcr->dir_bsock->spool = true; + dir->set_spooling(); } Dmsg0(850, "Send attributes to dir.\n"); if (!dir_update_file_attributes(jcr->dcr, rec)) { - jcr->dir_bsock->spool = false; + dir->clear_spooling(); Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"), - bnet_strerror(jcr->dir_bsock)); + dir->bstrerror()); return false; } - jcr->dir_bsock->spool = false; + dir->clear_spooling(); } }