[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bacula-devel] Fwd: [Bacula-users] Unlimited Retention


Yes, this looks like an oversight on my part.  The editing was done unsigned 
and it should have used signed numbers.

I've attached a patch to this email that should correct the problem.  I
have compiled the patch, but have not explicitly tested it with a long 
retention period, so feedback would be welcome.

Dan: thanks for reporting this.

Best regards,

Kern

On Thursday 23 October 2008 14:19:07 Dan Langille wrote:
> FYI
>
> Begin forwarded message:
> > From: LeJav <lejav@xxxxxxxxxxx>
> > Date: October 23, 2008 4:10:25 AM EDT
> > To: bacula-users@xxxxxxxxxxxxxxxxxxxxx
> > Subject: [Bacula-users] Unlimited Retention
> >
> > Hello,
> >
> > Here is my problem: I want to backup my system with normal strategy
> >  (full every week, incremental, retention....), but I have also data
> > on
> >  this server that I want to archive indefinitely (without retention).
> > To do that, i declared first retention period for this job as 100
> > years.
> > But it did not work.
> > Investigating in source code, I found that:
> >
> > ua_prune.c
> > ...
> >   period = client->FileRetention;
> >   now = (utime_t)time(NULL);
> >
> >   /* Select Jobs -- for counting */
> >   Mmsg(query, count_select_job, edit_uint64(now - period, ed1),
> >        edit_int64(cr.ClientId, ed2));
> >   Dmsg3(050, "select now=%u period=%u sql=%s\n", (uint32_t)now,
> >               (uint32_t)period, query.c_str());
> > ...
> >
> > and : time() returns the time since the Epoch (00:00:00 UTC, January
> > 1, 1970), measured in seconds.
> > for instance, today, now = 1224742378 = 38.8 years
> > this means that if i set a retention > 39 years, now-period will be
> > negative,
> >  and then a very very big number in unsigned int64, so jobs will be
> > always pruned
> >
> > for information, there is no such problem for volume retention:
> > next_vol.c :
> > ...
> >   if ((mr->LastWritten + mr->VolRetention) < (utime_t)time(NULL)
> > ...
> > everything is utime_t = int64_t
> >  so, there is here no problem
> >
> >
> > it would be nice to have for retention a keyword like "infinite".
> >
> > The solution I have found is to set AutoPrune = no for the client,
> > and to set
> >  pruning for files, jobs and volumes for the jobs which need it.
> >
> > Any other suggestion ?
> >
> > Thx
> >
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK & win
> > great prizes
> > Grand prize is a trip for two to an Open Source event anywhere in
> > the world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Bacula-users mailing list
> > Bacula-users@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.sourceforge.net/lists/listinfo/bacula-users


 This patch should fix the bug reported on the bacula-users list where
 a retention period of 100 years does immediate prunning.
 Apply it to 2.4.3 (or earlier versions) with:

 cd <bacula-source>
 patch -p0 <2.4.3-prune.patch
 ./configure <your-options>
 make
 ...
 make install

Index: src/dird/ua_prune.c
===================================================================
--- src/dird/ua_prune.c	(revision 7757)
+++ src/dird/ua_prune.c	(working copy)
@@ -202,7 +202,7 @@
    now = (utime_t)time(NULL);
 
    /* Select Jobs -- for counting */
-   Mmsg(query, count_select_job, edit_uint64(now - period, ed1), 
+   Mmsg(query, count_select_job, edit_int64(now - period, ed1), 
         edit_int64(cr.ClientId, ed2));
    Dmsg3(050, "select now=%u period=%u sql=%s\n", (uint32_t)now, 
                (uint32_t)period, query.c_str());
@@ -230,7 +230,7 @@
    del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
 
    /* Now process same set but making a delete list */
-   Mmsg(query, select_job, edit_uint64(now - period, ed1), 
+   Mmsg(query, select_job, edit_int64(now - period, ed1), 
         edit_int64(cr.ClientId, ed2));
    db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)&del);
 
@@ -318,7 +318,7 @@
     * Select all files that are older than the JobRetention period
     *  and stuff them into the "DeletionCandidates" table.
     */
-   edit_uint64(now - period, ed1);
+   edit_int64(now - period, ed1);
    Mmsg(query, insert_delcand, (char)JobType, ed1, 
         edit_int64(cr.ClientId, ed2));
    if (!db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL)) {
@@ -443,10 +443,10 @@
    edit_int64(mr->MediaId, ed1); 
    period = mr->VolRetention;
    now = (utime_t)time(NULL);
-   edit_uint64(now-period, ed2);
+   edit_int64(now-period, ed2);
    Mmsg(query, sel_JobMedia, ed1, ed2);
-   Dmsg3(250, "Now=%d period=%d now-period=%d\n", (int)now, (int)period,
-      (int)(now-period));
+   Dmsg3(250, "Now=%d period=%d now-period=%s\n", (int)now, (int)period,
+      ed2);
 
    Dmsg1(050, "Query=%s\n", query.c_str());
    if (!db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)del)) {
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilotco.