The main author of Bacula is Kern Sibbald, with contributions from
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
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
}
/* Must create it */
- Mmsg(mdb->cmd, "INSERT INTO Counters (Counter,MinValue,MaxValue,CurrentValue,"
+ Mmsg(mdb->cmd, "INSERT INTO Counters (Counter,\"MinValue\",\"MaxValue\",CurrentValue,"
"WrapCounter) VALUES ('%s','%d','%d','%d','%s')",
cr->Counter, cr->MinValue, cr->MaxValue, cr->CurrentValue,
cr->WrapCounter);
}
/*
- * Returns 1 if OK
- * 0 if failed
+ * Returns true if OK
+ * false if failed
*/
bool db_write_batch_file_records(JCR *jcr)
{
+ bool retval = false;
int JobStatus = jcr->JobStatus;
if (!jcr->batch_started) { /* no files to backup ? */
return true;
}
if (job_canceled(jcr)) {
- return false;
+ goto bail_out;
}
Dmsg1(50,"db_create_file_record changes=%u\n",jcr->db_batch->changes);
jcr->JobStatus = JS_AttrInserting;
if (!sql_batch_end(jcr, jcr->db_batch, NULL)) {
Jmsg1(jcr, M_FATAL, 0, "Batch end %s\n", jcr->db_batch->errmsg);
- return false;
+ goto bail_out;
}
if (job_canceled(jcr)) {
- return false;
+ goto bail_out;
}
-
- /* we have to lock tables */
+ /*
+ * We have to lock tables
+ */
if (!db_sql_query(jcr->db_batch, sql_batch_lock_path_query, NULL, NULL)) {
Jmsg1(jcr, M_FATAL, 0, "Lock Path table %s\n", jcr->db_batch->errmsg);
- return false;
+ goto bail_out;
}
if (!db_sql_query(jcr->db_batch, sql_batch_fill_path_query, NULL, NULL)) {
Jmsg1(jcr, M_FATAL, 0, "Fill Path table %s\n",jcr->db_batch->errmsg);
db_sql_query(jcr->db_batch, sql_batch_unlock_tables_query, NULL, NULL);
- return false;
+ goto bail_out;
}
if (!db_sql_query(jcr->db_batch, sql_batch_unlock_tables_query,NULL,NULL)) {
Jmsg1(jcr, M_FATAL, 0, "Unlock Path table %s\n", jcr->db_batch->errmsg);
- return false;
+ goto bail_out;
}
- /* we have to lock tables */
+ /*
+ * We have to lock tables
+ */
if (!db_sql_query(jcr->db_batch,sql_batch_lock_filename_query,NULL, NULL)) {
Jmsg1(jcr, M_FATAL, 0, "Lock Filename table %s\n", jcr->db_batch->errmsg);
- return false;
+ goto bail_out;
}
if (!db_sql_query(jcr->db_batch,sql_batch_fill_filename_query, NULL,NULL)) {
Jmsg1(jcr,M_FATAL,0,"Fill Filename table %s\n",jcr->db_batch->errmsg);
db_sql_query(jcr->db_batch, sql_batch_unlock_tables_query, NULL, NULL);
- return false;
+ goto bail_out;
}
if (!db_sql_query(jcr->db_batch, sql_batch_unlock_tables_query,NULL,NULL)) {
Jmsg1(jcr, M_FATAL, 0, "Unlock Filename table %s\n", jcr->db_batch->errmsg);
- return false;
+ goto bail_out;
}
if (!db_sql_query(jcr->db_batch,
- "INSERT INTO File (FileIndex, JobId, PathId, FilenameId, LStat, MD5)"
+ "INSERT INTO File (FileIndex, JobId, PathId, FilenameId, LStat, MD5) "
"SELECT batch.FileIndex, batch.JobId, Path.PathId, "
"Filename.FilenameId,batch.LStat, batch.MD5 "
"FROM batch "
NULL,NULL))
{
Jmsg1(jcr, M_FATAL, 0, "Fill File table %s\n", jcr->db_batch->errmsg);
- return false;
+ goto bail_out;
}
+ jcr->JobStatus = JobStatus; /* reset entry status */
+ retval = true;
+
+bail_out:
db_sql_query(jcr->db_batch, "DROP TABLE batch", NULL,NULL);
- jcr->JobStatus = JobStatus; /* reset entry status */
- return true;
+ return retval;
}
/**
bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ro)
{
bool stat;
- POOLMEM *esc_obj = get_pool_memory(PM_MESSAGE);
+ int plug_name_len;
+ POOLMEM *esc_plug_name = get_pool_memory(PM_MESSAGE);
+
db_lock(mdb);
Dmsg1(dbglevel, "Oname=%s\n", ro->object_name);
mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl*2+1);
db_escape_string(jcr, mdb, mdb->esc_name, ro->object_name, mdb->fnl);
- esc_obj = check_pool_memory_size(esc_obj, ro->object_len*2+1);
- db_escape_string(jcr, mdb, esc_obj, ro->object, ro->object_len);
+ db_escape_object(jcr, mdb, ro->object, ro->object_len);
+
+ plug_name_len = strlen(ro->plugin_name);
+ esc_plug_name = check_pool_memory_size(esc_plug_name, plug_name_len*2+1);
+ db_escape_string(jcr, mdb, esc_plug_name, ro->plugin_name, plug_name_len);
Mmsg(mdb->cmd,
- "INSERT INTO RestoreObject (ObjectName,RestoreObject,"
- "ObjectLength,ObjectIndex,ObjectType,ObjectCompression,FileIndex,JobId) "
- "VALUES ('%s','%s',%d,%d,%d,%d,%d,%u)",
- mdb->esc_name, esc_obj, ro->object_len, ro->object_index,
+ "INSERT INTO RestoreObject (ObjectName,PluginName,RestoreObject,"
+ "ObjectLength,ObjectFullLength,ObjectIndex,ObjectType,"
+ "ObjectCompression,FileIndex,JobId) "
+ "VALUES ('%s','%s','%s',%d,%d,%d,%d,%d,%d,%u)",
+ mdb->esc_name, esc_plug_name, mdb->esc_obj,
+ ro->object_len, ro->object_full_len, ro->object_index,
FT_RESTORE_FIRST, ro->object_compression, ro->FileIndex, ro->JobId);
ro->RestoreObjectId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("RestoreObject"));
stat = true;
}
db_unlock(mdb);
- free_pool_memory(esc_obj);
+ free_pool_memory(esc_plug_name);
return stat;
}