This bug fixes the LastWritten field which was updated during
  a restore (or a reading migration)
  This fixes bug #982

  This patch applies to Bacula version 2.2.5 (and previous versions),
  and can be applied with the following:

  cd <bacula-source>
  patch -p0 <2.2.5-lastwritten.patch
  ./configure (your options)
  make
  ...
  make install



Index: src/dird/catreq.c
===================================================================
--- src/dird/catreq.c	(révision 5789)
+++ src/dird/catreq.c	(copie de travail)
@@ -266,6 +266,11 @@
          }
       }
       Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
+      /* Check if the volume has been written by the job, 
+       * and update the LastWritten field if needed */
+      if (mr.VolBlocks != sdmr.VolBlocks) {
+         mr.LastWritten = sdmr.LastWritten;
+      }
       /* Copy updated values to original media record */
       mr.VolJobs      = sdmr.VolJobs;
       mr.VolFiles     = sdmr.VolFiles;
@@ -274,7 +279,6 @@
       mr.VolMounts    = sdmr.VolMounts;
       mr.VolErrors    = sdmr.VolErrors;
       mr.VolWrites    = sdmr.VolWrites;
-      mr.LastWritten  = sdmr.LastWritten;
       mr.Slot         = sdmr.Slot;
       mr.InChanger    = sdmr.InChanger;
       mr.VolReadTime  = sdmr.VolReadTime;


syntax highlighted by Code2HTML, v. 0.9.1