]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.4.2-inchanger.patch
Apply Joao's patch to SQLite tables to make chars work.
[bacula/bacula] / bacula / patches / 2.4.2-inchanger.patch
1
2   Attempt to fix bug #1128 InChanger flag cleared during Migration
3   job when reading from one autochanger and writing to another.
4   Testing is needed.
5   Apply this patch to Bacula version 2.4.2 with:
6
7   cd <bacula-source>
8   patch -p0 <2.4.2-inchanger.patch
9   ./configure <your options>
10   make
11   ...
12   make install
13
14
15 Index: src/dird/catreq.c
16 ===================================================================
17 --- src/dird/catreq.c   (revision 7507)
18 +++ src/dird/catreq.c   (working copy)
19 @@ -83,7 +83,7 @@
20     jcr->MediaId = mr->MediaId;
21     pm_strcpy(jcr->VolumeName, mr->VolumeName);
22     bash_spaces(mr->VolumeName);
23 -   stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs,
24 +   stat = sd->fsend(OK_media, mr->VolumeName, mr->VolJobs,
25        mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
26        mr->VolMounts, mr->VolErrors, mr->VolWrites,
27        edit_uint64(mr->MaxVolBytes, ed2),
28 @@ -266,11 +266,22 @@
29           }
30        }
31        Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
32 +
33        /* Check if the volume has been written by the job, 
34         * and update the LastWritten field if needed */
35        if (mr.VolBlocks != sdmr.VolBlocks) {
36           mr.LastWritten = sdmr.LastWritten;
37        }
38 +
39 +      /*
40 +       * Update to point to the last device used to write the Volume.
41 +       *   However, do so only if we are writing the tape, i.e.
42 +       *   the number of VolWrites has increased.
43 +       */
44 +      if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
45 +         mr.StorageId = jcr->wstore->StorageId;
46 +      }
47 +
48        /* Copy updated values to original media record */
49        mr.VolJobs      = sdmr.VolJobs;
50        mr.VolFiles     = sdmr.VolFiles;
51 @@ -285,14 +296,6 @@
52        mr.VolWriteTime = sdmr.VolWriteTime;
53        mr.VolParts     = sdmr.VolParts;
54        bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
55 -      /*
56 -       * Update to point to the last device used to write the Volume.
57 -       *   However, do so only if we are writing the tape, i.e.
58 -       *   the number of VolBlocks has increased.
59 -       */
60 -      if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) {
61 -         mr.StorageId = jcr->wstore->StorageId;
62 -      }
63  
64        Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
65        /*
66 Index: src/dird/dird.c
67 ===================================================================
68 --- src/dird/dird.c     (revision 7507)
69 +++ src/dird/dird.c     (working copy)
70 @@ -914,6 +914,7 @@
71           db_create_storage_record(NULL, db, &sr);
72           store->StorageId = sr.StorageId;   /* set storage Id */
73           if (!sr.created) {                 /* if not created, update it */
74 +            sr.AutoChanger = store->autochanger;
75              db_update_storage_record(NULL, db, &sr);
76           }
77  
78 Index: src/cats/sql_update.c
79 ===================================================================
80 --- src/cats/sql_update.c       (revision 7507)
81 +++ src/cats/sql_update.c       (working copy)
82 @@ -1,7 +1,7 @@
83  /*
84     Bacula® - The Network Backup Solution
85  
86 -   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
87 +   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
88  
89     The main author of Bacula is Kern Sibbald, with contributions from
90     many others, a complete list can be found in the file AUTHORS.
91 @@ -445,7 +445,8 @@
92  db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
93  {
94     char ed1[50], ed2[50];
95 -   if (mr->InChanger != 0 && mr->Slot != 0) {
96 +   if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 &&
97 +       mr->MediaId != 0) {
98        Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
99             "Slot=%d AND StorageId=%s AND MediaId!=%s",
100              mr->Slot,