From: Eric Bollengier Date: Fri, 3 Mar 2023 14:55:49 +0000 (+0100) Subject: Prune Object records when pruning Files X-Git-Tag: Beta-15.0.0~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7da79bd8b524ad38cc274e5bb8c825066036aac6;p=thirdparty%2Fbacula.git Prune Object records when pruning Files --- diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index e95e60874..7a764de51 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -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? */