]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Prune Object records when pruning Files
authorEric Bollengier <eric@baculasystems.com>
Fri, 3 Mar 2023 14:55:49 +0000 (15:55 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
bacula/src/dird/ua_purge.c

index e95e608749d188473b5d64e101a62e59e7994768..7a764de511891f8abe4f560cf813fa7425117a5e 100644 (file)
@@ -373,10 +373,6 @@ void purge_files_from_jobs(UAContext *ua, char *jobs)
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete MetaAttachment sql=%s\n", query.c_str());
 
-   Mmsg(query, "DELETE FROM TagJob WHERE JobId IN (%s)", jobs);
-   db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
-   Dmsg1(050, "Delete TagJob sql=%s\n", query.c_str());
-
    Mmsg(query, "DELETE FROM File WHERE JobId IN (%s)", jobs);
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete File sql=%s\n", query.c_str());
@@ -393,6 +389,14 @@ void purge_files_from_jobs(UAContext *ua, char *jobs)
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete PathVisibility sql=%s\n", query.c_str());
 
+   Mmsg(query, "DELETE FROM Object WHERE JobId IN (%s)", jobs);
+   db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
+   Dmsg1(050, "Delete Object 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());
+
    /*
     * Now mark Job as having files purged. This is necessary to
     * avoid having too many Jobs to process in future prunings. If
@@ -534,22 +538,18 @@ 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());
 
-   Mmsg(query, "DELETE FROM Object WHERE JobId IN (%s)", jobs);
-   db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
-   Dmsg1(050, "Delete Object sql=%s\n", query.c_str());
-
    Mmsg(query, "DELETE FROM RestoreObject WHERE JobId IN (%s)", jobs);
    db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
    Dmsg1(050, "Delete RestoreObject sql=%s\n", query.c_str());
 
+   Mmsg(query, "DELETE FROM TagJob WHERE JobId IN (%s)", jobs);
+   db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
+   Dmsg1(050, "Delete TagJob sql=%s\n", query.c_str());
+
    /* The JobId of the Snapshot record is no longer usable
     * TODO: Migth want to use a copy for the jobid?
     */