From 3bacdad8b0a50c6c919c2ee6ce43c68e916f7f69 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 19 May 2003 19:24:18 +0000 Subject: [PATCH] Update doc, kernstodo and minor purge bug git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@518 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 38 +++++++++++++++++++++++++++++++++ bacula/src/dird/sql_cmds.c | 42 +++++++++++++++++++++++++++---------- bacula/src/dird/ua_prune.c | 8 ++++--- bacula/src/dird/ua_purge.c | 14 ++++++------- bacula/src/dird/ua_select.c | 5 ++++- 5 files changed, 85 insertions(+), 22 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 909f328a67..16c9253bdb 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -19,6 +19,12 @@ Testing to do: (painful) - Figure out how to use ssh or stunnel to protect Bacula communications. For 1.31 release: +- Document what characters can go into Volume names. +- Implement Volume name checking. +- 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. @@ -34,6 +40,38 @@ For 1.31 release: - Possibly update all client records at startup. - Volume names with spaces get jammed into the catalog with 0x1 i.e. the SD bashes the Volume but they are not unbased by Dir. + jerom-dir: MonthlySave.2003-05-10_17.12.01 Error: Unable to get Media + record for Volume Tape^A1: ERR=sql_get.c:788 Media record for Volume + "Tape^A1" not found. + jerom-sd: MonthlySave.2003-05-10_17.12.01 Error: Error updating Volume + Info: 1991 Catalog Request failed: sql_get.c:788 Media record for Volume + "Tape^A1" not found. + +- Cancellation caused JobMedia error: + babylon5-dir: Last FULL backup time not found. Doing FULL backup. + babylon5-dir: Start Backup JobId 416, Job=Zocalo_Save.2003-05-19_02.15.06 + babylon5-sd: End of media on Volume VXA-V17-Inc-001 Bytes=31,982,900,672 Blocks=495,781. + babylon5-sd: Job Zocalo_Save.2003-05-19_02.15.06 waiting. Cannot find any appendable volumes. + babylon5-sd: Someone woke me up, but I cannot find any appendable volumes + for Job=Zocalo_Save.2003-05-19_02.15.06. + babylon5-sd: Zocalo_Save.2003-05-19_02.15.06 Fatal error: Job + Zocalo_Save.2003-05-19_02.15.06 canceled while waiting for mount on + Storage Device "Ecrix_VXA-1". + babylon5-sd: Zocalo_Save.2003-05-19_02.15.06 Fatal error: Cannot fixup device + error. Job Zocalo_Save.2003-05-19_02.15.06 canceled while waiting for + mount on Storage Device "Ecrix_VXA-1". + + babylon5-dir: Zocalo_Save.2003-05-19_02.15.06 Error: Catalog error creating + JobMedia record. sql_create.c:125 Create JobMedia failed. Record already + exists. + babylon5-sd: Zocalo_Save.2003-05-19_02.15.06 Error: Error creating JobMedia + record: 1991 Update JobMedia error + + babylon5-sd: Zocalo_Save.2003-05-19_02.15.06 Error: askdir.c:158 NULL Volume + name. This shouldn't happen!!! + zocalo-fd: Zocalo_Save.2003-05-19_02.15.06 Error: bnet.c:310 Write error + sending to Storage daemon:babylon5:9103: ERR=Broken pipe + - ChangeServiceConfig2A does not exist on WinNT (ADVAPI32.DLL). diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index 84a73ff53b..492519ea3a 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -62,37 +62,57 @@ char *create_deltabs[] = { "CREATE TABLE DelCandidates (" "JobId INTEGER UNSIGNED NOT NULL, " "PurgedFiles TINYINT, " - "FileSetId INTEGER UNSIGNED)", + "FileSetId INTEGER UNSIGNED, " + "JobFiles INTEGER UNSIGNED, " +#ifdef HAVE_MYSQL + "JobStatus BINARY(1))", +#else + "JobStatus CHAR)", +#endif "CREATE INDEX DelInx1 ON DelCandidates (JobId)", NULL}; -/* Fill candidates table with all Files subject to being deleted. +/* Fill candidates table with all Jobs subject to being deleted. * This is used for pruning Jobs (first the files, then the Jobs). */ char *insert_delcand = "INSERT INTO DelCandidates " - "SELECT JobId, PurgedFiles, FileSetId FROM Job " + "SELECT JobId,PurgedFiles,FileSetId,JobFiles,JobStatus FROM Job " "WHERE Type='%c' " "AND JobTDate<%s " "AND ClientId=%u"; -/* Select files from the DelCandidates table that have a +/* Select Jobs from the DelCandidates table that have a * more recent backup -- i.e. are not the only backup. - * This is the list of files to delete for a Backup Job. + * 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 Job.JobTDate>%s " + "WHERE (DelCandidates.JobFiles=0) OR " + "(NOT 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"; + "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 -/* Select files from the DelCandidates table that have a +/* Select Jobs from the DelCandidates table that have a * more recent InitCatalog -- i.e. are not the only InitCatalog - * This is the list of files to delete for a Verify Job. + * This is the list of Jobs to delete for a Verify Job. */ char *select_verify_del = "SELECT DelCandidates.JobId " @@ -105,8 +125,8 @@ char *select_verify_del = "AND Job.FileSetId=DelCandidates.FileSetId"; -/* Select files from the DelCandidates table. - * This is the list of files to delete for a Restore Job. +/* Select Jobs from the DelCandidates table. + * This is the list of Jobs to delete for a Restore Job. */ char *select_restore_del = "SELECT DelCandidates.JobId " diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index fa93fafed5..58259da5c0 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -184,14 +184,14 @@ int prunecmd(UAContext *ua, char *cmd) switch (kw) { case 0: /* prune files */ - client = select_client_resource(ua); + client = get_client_resource(ua); if (!client || !confirm_retention(ua, &client->FileRetention, "File")) { return 0; } prune_files(ua, client); return 1; case 1: /* prune jobs */ - client = select_client_resource(ua); + client = get_client_resource(ua); if (!client || !confirm_retention(ua, &client->JobRetention, "Job")) { return 0; } @@ -437,7 +437,8 @@ 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(050, "Delete JobId=%d\n", del.JobId[i]); + Dmsg1(000, "Delete JobId=%d\n", del.JobId[i]); +#ifdef xxx if (!del.PurgedFiles[i]) { Mmsg(&query, del_File, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { @@ -457,6 +458,7 @@ 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); diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index e5eb298c87..b77c2b079b 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -261,7 +261,7 @@ int purgecmd(UAContext *ua, char *cmd) } /* - * Prune File records from the database. For any Job which + * Purge File records from the database. For any Job which * is older than the retention period, we unconditionally delete * all File records for that Job. This is simple enough that no * temporary tables are needed. We simply make an in memory list of @@ -338,12 +338,12 @@ bail_out: /* - * Purging Jobs is a bit more complicated than purging Files - * because we delete Job records only if there is a more current - * backup of the FileSet. Otherwise, we keep the Job record. - * In other words, we never delete the only Job record that - * contains a current backup of a FileSet. This prevents the - * Volume from being recycled and destroying a current backup. + * Purge Job records from the database. For any Job which + * is older than the retention period, we unconditionally delete + * it and all File records for that Job. This is simple enough that no + * temporary tables are needed. We simply make an in memory list of + * the JobIds meeting the prune conditions, then delete the Job, + * Files, and JobMedia records in that list. */ int purge_jobs_from_client(UAContext *ua, CLIENT *client) { diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 5948cfc10b..277a9e3fb8 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -57,7 +57,10 @@ int confirm_retention(UAContext *ua, utime_t *ret, char *msg) continue; } if (strcasecmp(ua->cmd, _("yes")) == 0) { - break; + return 1; + } + if (strcasecmp(ua->cmd, _("no")) == 0) { + return 0; } } return 1; -- 2.39.5