]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/dird/ua_purge.c
authorEric Bollengier <eric@baculasystems.com>
Fri, 24 Apr 2020 16:04:14 +0000 (18:04 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:17 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Oct 4 09:20:43 2019 +0200

    Do not purge running jobs in purge_job_list_from_catalog()

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Jul 13 14:00:14 2018 +0200

    Fix GCC 8 compiler warnings with memset() on objects

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue May 17 11:16:02 2016 +0200

    Add BEEF marks for FileMedia feature

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Apr 5 18:55:10 2016 +0200

    Implement FileMedia feature and FO_OFFSETS for plugin

     - Allow plugins to use the FO_OFFSETS option
     - Add SQL support in cats
     - Add bvfs commands
     - Add FileMedia handling in the Storage Daemon
     - Add use FO_OFFSETS option in test plugin
     - Add new sql scripts to configure.in
     - Update catalog version to 1018

Author: Kern Sibbald <kern@sibbald.com>
Date:   Fri Apr 17 18:33:35 2015 +0200

    Refactor DB engine to be class based

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Thu Jun 27 11:51:35 2013 +0200

    Fix #7777 about a warning message when using purge action=truncate command

bacula/src/dird/ua_purge.c

index 9484f2df457f27742d9a27e531a160207ef9982a..6fbe232cb1c4833d4ba60c35d2aa8860c0e58eee 100644 (file)
@@ -292,6 +292,10 @@ void purge_files_from_jobs(UAContext *ua, char *jobs)
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete File sql=%s\n", query.c_str());
 
+   Mmsg(query, "DELETE FROM FileMedia WHERE JobId IN (%s)", jobs);
+   db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
+   Dmsg1(050, "Delete FileMedia sql=%s\n", query.c_str());
+
    Mmsg(query, "DELETE FROM BaseFiles WHERE JobId IN (%s)", jobs);
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete BaseFiles sql=%s\n", query.c_str());
@@ -320,6 +324,8 @@ void purge_job_list_from_catalog(UAContext *ua, del_ctx &del)
    POOL_MEM jobids(PM_MESSAGE);
    char ed1[50];
 
+   exclude_running_jobs_from_list(&del);
+
    for (int i=0; del.num_ids; ) {
       Dmsg1(150, "num_ids=%d\n", del.num_ids);
       pm_strcat(jobids, "");
@@ -427,6 +433,10 @@ void purge_jobs_from_catalog(UAContext *ua, char *jobs)
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete JobMedia sql=%s\n", query.c_str());
 
+   Mmsg(query, "DELETE FROM FileMedia WHERE JobId IN (%s)", jobs);
+   db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
+   Dmsg1(050, "Delete JobMedia sql=%s\n", query.c_str());
+
    Mmsg(query, "DELETE FROM Log WHERE JobId IN (%s)", jobs);
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete Log sql=%s\n", query.c_str());
@@ -442,7 +452,6 @@ void purge_jobs_from_catalog(UAContext *ua, char *jobs)
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
 
    upgrade_copies(ua, jobs);
-
    /* Now remove the Job record itself */
    Mmsg(query, "DELETE FROM Job WHERE JobId IN (%s)", jobs);
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
@@ -684,8 +693,8 @@ int truncate_cmd(UAContext *ua, const char *cmd)
    if (find_arg(ua, "cache") > 0) {
       return cloud_volumes_cmd(ua, cmd, "truncate cache");
    }
-
-   memset(&pr, 0, sizeof(pr));
+   
+   bmemset(&pr, 0, sizeof(pr));
 
    /*
     * Look for all Purged volumes that can be recycled, are enabled and
@@ -773,8 +782,8 @@ bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr)
        */
       if (mr->RecyclePoolId && mr->RecyclePoolId != mr->PoolId) {
          POOL_DBR oldpr, newpr;
-         memset(&oldpr, 0, sizeof(POOL_DBR));
-         memset(&newpr, 0, sizeof(POOL_DBR));
+         bmemset(&oldpr, 0, sizeof(POOL_DBR));
+         bmemset(&newpr, 0, sizeof(POOL_DBR));
          newpr.PoolId = mr->RecyclePoolId;
          oldpr.PoolId = mr->PoolId;
          if (   db_get_pool_numvols(jcr, ua->db, &oldpr)