]> git.sur5r.net Git - bacula/bacula/commitdiff
Prune jobs with no JobFiles or that err
authorKern Sibbald <kern@sibbald.com>
Mon, 19 May 2003 21:13:16 +0000 (21:13 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 19 May 2003 21:13:16 +0000 (21:13 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@520 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/dird/sql_cmds.c
bacula/src/dird/ua_prune.c
bacula/src/dird/ua_purge.c
bacula/src/version.h

index 16c9253bdb1ea763af1b5077b365863e3b0c7228..d069123d4c435899baa2a0e3f8ec26ab5ba62b5d 100644 (file)
@@ -24,11 +24,12 @@ For 1.31 release:
 - Default duration with no qualifier is sec should be 1 day
 - Getting the following on all directories on Win32
   19-May-2003 01:14 tibs-fd:      Could not access c:/cygwin/home/kern/rxvt: ERR=Permission denied
-- Make sure Bacula prunes/purges canceled and failed jobs too!
 - Find a solution for the multiple FileSet problem (when it is changed).
   Add date?
 - Cancel waiting for Client connect in SD if FD goes away.
-- Testing Tibs job erred and hung director on Storage resource.
+- Testing Tibs job erred and hung director on Storage resource.  This was
+  because there were a whole pile of jobs hanging around in the SD  
+  waiting for a connection from the FD that was never coming.
 - Make restore more robust in counting error and not immediately bailing
   out. Also print error message once, but try to continue.
 - Make SD keep track of Files, Bytes during restore.
@@ -868,4 +869,5 @@ Done: (see kernsdone for more)
 - Make default duration days if no qualifier (e.g. s) is specified.
 - BSDI fix finding gcc version
 - When the FD errs (e.g. disk full) have a more graceful shutdown.
+- Make sure Bacula prunes/purges canceled and failed jobs too and all
+  jobs with zero JobFiles.
index 492519ea3a6d2b91477c7e9cc846d3b8cd7c11e0..e1aa5674a403354688cc617103b28c828ddc10e8 100644 (file)
@@ -86,29 +86,18 @@ char *insert_delcand =
  * more recent backup -- i.e. are not the only backup.
  * This is the list of Jobs to delete for a Backup Job.
  */
-#ifdef xxx
 char *select_backup_del =
    "SELECT DelCandidates.JobId "
    "FROM Job,DelCandidates "
    "WHERE (DelCandidates.JobFiles=0) OR "
-   "(NOT DelCandidates.JobStatus='T') OR "
+   "(DelCandidates.JobStatus!='T') OR "
    "(Job.JobTDate>%s "
    "AND Job.ClientId=%u "
    "AND Job.Type='B' "
    "AND Job.Level='F' "
    "AND Job.JobStatus='T' "
-   "AND Job.FileSetId=DelCandidates.FileSetId)";
-#else
-char *select_backup_del =
-   "SELECT DelCandidates.JobId "
-   "FROM Job,DelCandidates "
-   "WHERE (Job.JobTDate>%s "
-   "AND Job.ClientId=%u "
-   "AND Job.Type='B' "
-   "AND Job.Level='F' "
-   "AND Job.JobStatus='T' "
-   "AND Job.FileSetId=DelCandidates.FileSetId)";
-#endif
+   "AND Job.FileSetId=DelCandidates.FileSetId) "
+   "GROUP BY JobId";
 
 /* Select Jobs from the DelCandidates table that have a
  * more recent InitCatalog -- i.e. are not the only InitCatalog
@@ -122,7 +111,8 @@ char *select_verify_del =
    "AND Job.Type='V' "
    "AND Job.Level='V' "
    "AND Job.JobStatus='T' "
-   "AND Job.FileSetId=DelCandidates.FileSetId";
+   "AND Job.FileSetId=DelCandidates.FileSetId "
+   "GROUP BY JobId";
 
 
 /* Select Jobs from the DelCandidates table.
@@ -133,7 +123,8 @@ char *select_restore_del =
    "FROM Job,DelCandidates "
    "WHERE Job.JobTDate>%s "
    "AND Job.ClientId=%u "   
-   "AND Job.Type='R'";
+   "AND Job.Type='R' "
+   "GROUP BY JobId";
 
 
 
index b8d312b28631fb3767d38475d4e9302b1dd9b810..447f468dc7a450e689e4939a8e21c11f592f6756 100644 (file)
@@ -237,7 +237,7 @@ int prune_files(UAContext *ua, CLIENT *client)
    db_lock(ua->db);
    memset(&cr, 0, sizeof(cr));
    memset(&del, 0, sizeof(del));
-   strcpy(cr.Name, client->hdr.name);
+   bstrncpy(cr.Name, client->hdr.name, sizeof(cr.Name));
    if (!db_create_client_record(ua->jcr, ua->db, &cr)) {
       db_unlock(ua->db);
       return 0;
@@ -359,7 +359,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
    db_lock(ua->db);
    memset(&cr, 0, sizeof(cr));
    memset(&del, 0, sizeof(del));
-   strcpy(cr.Name, client->hdr.name);
+   bstrncpy(cr.Name, client->hdr.name, sizeof(cr.Name));
    if (!db_create_client_record(ua->jcr, ua->db, &cr)) {
       db_unlock(ua->db);
       return 0;
@@ -391,7 +391,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
    }
 
    /* Count Files to be deleted */
-   strcpy(query, cnt_DelCand);
+   pm_strcpy(&query, cnt_DelCand);
    Dmsg1(100, "select sql=%s\n", query);
    cnt.count = 0;
    if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) {
@@ -437,9 +437,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
     * Then delete the Job entry, and finally and JobMedia records.
     */
    for (i=0; i < del.num_ids; i++) {
-      Dmsg1(100, "Delete JobId=%d\n", del.JobId[i]);
-#define xxx
-#ifdef xxx
+      Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]);
       if (!del.PurgedFiles[i]) {
         Mmsg(&query, del_File, del.JobId[i]);
         if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) {
@@ -459,7 +457,6 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
          bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg1(050, "Del sql=%s\n", query);
-#endif
    }
    bsendmsg(ua, _("Pruned %d %s for client %s from catalog.\n"), del.num_ids,
       del.num_ids==1?_("Job"):_("Jobs"), client->hdr.name);
index b77c2b079b031f656422b87111475b0ff654b32f..f943fbcd0f255be236c5881cbc8028be2f22b4bb 100644 (file)
@@ -205,8 +205,10 @@ int purgecmd(UAContext *ua, char *cmd)
         }
         return 1;
       case 2:                        /* client */
-        client = select_client_resource(ua);
-        purge_files_from_client(ua, client);
+        client = get_client_resource(ua);
+        if (client) {
+           purge_files_from_client(ua, client);
+        }
         return 1;
       case 3:                        /* Volume */
         if (select_media_dbr(ua, &mr)) {
@@ -218,8 +220,10 @@ int purgecmd(UAContext *ua, char *cmd)
    case 1:
       switch(find_arg_keyword(ua, jobs_keywords)) {
       case 0:                        /* client */
-        client = select_client_resource(ua);
-        purge_jobs_from_client(ua, client);
+        client = get_client_resource(ua);
+        if (client) {
+           purge_jobs_from_client(ua, client);
+        }
         return 1;
       case 1:                        /* Volume */
         if (select_media_dbr(ua, &mr)) {
@@ -238,18 +242,16 @@ int purgecmd(UAContext *ua, char *cmd)
    }
    switch (do_keyword_prompt(ua, _("Choose item to purge"), keywords)) {
    case 0:                           /* files */
-      client = select_client_resource(ua);
-      if (!client) {
-        return 1;
+      client = get_client_resource(ua);
+      if (client) {
+        purge_files_from_client(ua, client);
       }
-      purge_files_from_client(ua, client);
       break;
    case 1:                           /* jobs */
-      client = select_client_resource(ua);
-      if (!client) {
-        return 1;
+      client = get_client_resource(ua);
+      if (client) {
+        purge_jobs_from_client(ua, client);
       }
-      purge_jobs_from_client(ua, client);
       break;
    case 2:                           /* Volume */
       if (select_media_dbr(ua, &mr)) {
@@ -355,7 +357,7 @@ int purge_jobs_from_client(UAContext *ua, CLIENT *client)
    memset(&cr, 0, sizeof(cr));
    memset(&del, 0, sizeof(del));
 
-   strcpy(cr.Name, client->hdr.name);
+   bstrncpy(cr.Name, client->hdr.name, sizeof(cr.Name));
    if (!db_create_client_record(ua->jcr, ua->db, &cr)) {
       return 0;
    }
index 85459f8637872bfb535875f59a22626b89da9780..499457ade47122f0632b5004e8d30b467a7de530 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.31"
 #define VSTRING "1"
-#define BDATE   "18 May 2003"
-#define LSMDATE "18May03"
+#define BDATE   "19 May 2003"
+#define LSMDATE "19May03"
 
 /* Debug flags */
 #define DEBUG 1