-/*
- *
- * Program to check a Bacula database for consistency and to
- * make repairs
- *
- * Kern E. Sibbald, August 2002
- *
- * Version $Id$
- *
- */
/*
Bacula® - The Network Backup Solution
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation plus additions
- that are listed in the file LICENSE.
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Program to check a Bacula database for consistency and to
+ * make repairs
+ *
+ * Kern E. Sibbald, August 2002
+ *
+ * Version $Id$
+ *
+ */
#include "bacula.h"
#include "cats/cats.h"
" -b batch mode\n"
" -C catalog name in the director conf file\n"
" -c director conf filename\n"
-" -dnn set debug level to nn\n"
+" -d <nn> set debug level to <nn>\n"
+" -dt print timestamp in debug output\n"
" -f fix inconsistencies\n"
" -v verbose\n"
" -? print this message\n\n");
break;
case 'd': /* debug level */
- debug_level = atoi(optarg);
- if (debug_level <= 0)
- debug_level = 1;
+ if (*optarg == 't') {
+ dbg_timestamp = true;
+ } else {
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
+ }
break;
case 'f': /* fix inconsistencies */
/* Loop through list of duplicate names */
for (int i=0; i<name_list.num_ids; i++) {
/* Get all the Ids of each name */
- db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+ db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i]));
bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
if (verbose > 1) {
printf("%s\n", buf);
/* Loop through list of duplicate names */
for (int i=0; i<name_list.num_ids; i++) {
/* Get all the Ids of each name */
- db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+ db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i]));
bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
if (verbose > 1) {
printf("%s\n", buf);
if (fix && id_list.num_ids > 0) {
printf(_("Deleting %d orphaned JobMedia records.\n"), id_list.num_ids);
delete_id_list("DELETE FROM JobMedia WHERE JobMediaId=%s", &id_list);
+ } else {
+ break; /* get out if not updating db */
}
if (!make_id_list(query, &id_list)) {
exit(1);
if (fix && id_list.num_ids > 0) {
printf(_("Deleting %d orphaned File records.\n"), id_list.num_ids);
delete_id_list("DELETE FROM File WHERE FileId=%s", &id_list);
+ } else {
+ break; /* get out if not updating db */
}
if (!make_id_list(query, &id_list)) {
exit(1);
if (fix && id_list.num_ids > 0) {
printf(_("Deleting %d orphaned Path records.\n"), id_list.num_ids);
delete_id_list("DELETE FROM Path WHERE PathId=%s", &id_list);
+ } else {
+ break; /* get out if not updating db */
}
if (!make_id_list(query, &id_list)) {
exit(1);
if (fix && id_list.num_ids > 0) {
printf(_("Deleting %d orphaned Filename records.\n"), id_list.num_ids);
delete_id_list("DELETE FROM Filename WHERE FilenameId=%s", &id_list);
+ } else {
+ break; /* get out if not updating db */
}
if (!make_id_list(query, &id_list)) {
exit(1);
esc_name[1] = 0;
} else {
name[len-1] = 0;
- db_escape_string(esc_name, name, len);
+ db_escape_string(NULL, db, esc_name, name, len);
}
bsnprintf(buf, sizeof(buf),
"UPDATE Filename SET Name='%s' WHERE FilenameId=%s",
}
/* Add trailing slash */
len = pm_strcat(&name, "/");
- db_escape_string(esc_name, name, len);
+ db_escape_string(NULL, db, esc_name, name, len);
bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%s",
esc_name, edit_int64(id_list.Id[i], ed1));
if (verbose > 1) {