+ /*
+ * We have two loops here. The first comes from the
+ * Storage = associated with the Job, and we need
+ * to attach to each one.
+ * The inner loop loops over all the alternative devices
+ * associated with each Storage. It selects the first
+ * available one.
+ *
+ */
+ /* Do read side of storage daemon */
+ if (ok && rstore) {
+ /* For the moment, only migrate, copy and vbackup have rpool */
+ if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY) ||
+ (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL))) {
+ pm_strcpy(pool_type, jcr->rpool->pool_type);
+ pm_strcpy(pool_name, jcr->rpool->name());
+ } else {
+ pm_strcpy(pool_type, jcr->pool->pool_type);
+ pm_strcpy(pool_name, jcr->pool->name());
+ }
+ bash_spaces(pool_type);
+ bash_spaces(pool_name);
+ foreach_alist(storage, rstore) {
+ Dmsg1(100, "Rstore=%s\n", storage->name());
+ pm_strcpy(store_name, storage->name());
+ bash_spaces(store_name);
+ pm_strcpy(media_type, storage->media_type);
+ bash_spaces(media_type);
+ sd->fsend(use_storage, store_name.c_str(), media_type.c_str(),
+ pool_name.c_str(), pool_type.c_str(), 0, copy, stripe);
+ Dmsg1(100, "rstore >stored: %s", sd->msg);
+ DEVICE *dev;
+ /* Loop over alternative storage Devices until one is OK */
+ foreach_alist(dev, storage->device) {
+ pm_strcpy(device_name, dev->name());
+ bash_spaces(device_name);
+ sd->fsend(use_device, device_name.c_str());
+ Dmsg1(100, ">stored: %s", sd->msg);
+ }
+ sd->signal(BNET_EOD); /* end of Devices */
+ }
+ sd->signal(BNET_EOD); /* end of Storages */
+ if (bget_dirmsg(sd) > 0) {
+ Dmsg1(100, "<stored: %s", sd->msg);
+ /* ****FIXME**** save actual device name */
+ ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
+ } else {
+ ok = false;
+ }
+ }
+
+ /* Do write side of storage daemon */
+ if (ok && wstore) {