2
Attempt to fix bug #1128 InChanger flag cleared during Migration
3
job when reading from one autochanger and writing to another.
5
Apply this patch to Bacula version 2.4.2 with:
8
patch -p0 <2.4.2-inchanger.patch
9
./configure <your options>
15
Index: src/dird/catreq.c
16
===================================================================
17
--- src/dird/catreq.c (revision 7507)
18
+++ src/dird/catreq.c (working copy)
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),
31
Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
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;
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.
44
+ if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
45
+ mr.StorageId = jcr->wstore->StorageId;
48
/* Copy updated values to original media record */
49
mr.VolJobs = sdmr.VolJobs;
50
mr.VolFiles = sdmr.VolFiles;
52
mr.VolWriteTime = sdmr.VolWriteTime;
53
mr.VolParts = sdmr.VolParts;
54
bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
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.
60
- if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) {
61
- mr.StorageId = jcr->wstore->StorageId;
64
Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
66
Index: src/dird/dird.c
67
===================================================================
68
--- src/dird/dird.c (revision 7507)
69
+++ src/dird/dird.c (working copy)
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);
78
Index: src/cats/sql_update.c
79
===================================================================
80
--- src/cats/sql_update.c (revision 7507)
81
+++ src/cats/sql_update.c (working copy)
84
Bacula® - The Network Backup Solution
86
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
87
+ Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
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.
92
db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
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 &&
98
Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
99
"Slot=%d AND StorageId=%s AND MediaId!=%s",