2 This patch should fix the bug reported on the bacula-users list where
3 a retention period of 100 years does immediate prunning.
4 Apply it to 2.4.3 (or earlier versions) with:
7 patch -p0 <2.4.3-prune.patch
8 ./configure <your-options>
13 Index: src/dird/ua_prune.c
14 ===================================================================
15 --- src/dird/ua_prune.c (revision 7757)
16 +++ src/dird/ua_prune.c (working copy)
18 now = (utime_t)time(NULL);
20 /* Select Jobs -- for counting */
21 - Mmsg(query, count_select_job, edit_uint64(now - period, ed1),
22 + Mmsg(query, count_select_job, edit_int64(now - period, ed1),
23 edit_int64(cr.ClientId, ed2));
24 Dmsg3(050, "select now=%u period=%u sql=%s\n", (uint32_t)now,
25 (uint32_t)period, query.c_str());
27 del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
29 /* Now process same set but making a delete list */
30 - Mmsg(query, select_job, edit_uint64(now - period, ed1),
31 + Mmsg(query, select_job, edit_int64(now - period, ed1),
32 edit_int64(cr.ClientId, ed2));
33 db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)&del);
36 * Select all files that are older than the JobRetention period
37 * and stuff them into the "DeletionCandidates" table.
39 - edit_uint64(now - period, ed1);
40 + edit_int64(now - period, ed1);
41 Mmsg(query, insert_delcand, (char)JobType, ed1,
42 edit_int64(cr.ClientId, ed2));
43 if (!db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL)) {
45 edit_int64(mr->MediaId, ed1);
46 period = mr->VolRetention;
47 now = (utime_t)time(NULL);
48 - edit_uint64(now-period, ed2);
49 + edit_int64(now-period, ed2);
50 Mmsg(query, sel_JobMedia, ed1, ed2);
51 - Dmsg3(250, "Now=%d period=%d now-period=%d\n", (int)now, (int)period,
53 + Dmsg3(250, "Now=%d period=%d now-period=%s\n", (int)now, (int)period,
56 Dmsg1(050, "Query=%s\n", query.c_str());
57 if (!db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)del)) {