2003-07-xx Version 1.31 Beta xxJul03
+- Lock database while recycling.
+- Fix a bug in editing since where I forgot to update to the new size.
+- Implement all the command line update arguments.
+- Modify label to use volume=xxx for the new volume and oldvolume=yyy
+ if doing a relable.
+- Added yes to run command line arguments.
+- Clear errno in editing a string to utime.
- In restore print only volumes that will actually be used.
- Fix bextract -- add appropriate breaks in new case code.
- Add a new test -- bsr-opt-test for testing bsr optimization. As usual,
- Figure out how to use ssh or stunnel to protect Bacula communications.
For 1.31 release:
+- Complete (or turn off) the command line code in update.
- In Win portable restore the directory is not create
27-Jun-2003 16:52 tibs-fd: kernsrestore.2003-06-27_16.52.20 Error:
create_file.c:175 Could not create
Constrain FileIndex to be within range for Volume.
- Pass prefix_links to FD.
- Fix restore list of volumes if Volume not selected.
-
/*
* Find the Next Volume for Append
*/
+ db_lock(jcr->db);
for ( ;; ) {
strcpy(mr.VolStatus, "Append"); /* want only appendable volumes */
ok = db_find_next_volume(jcr, jcr->db, index, &mr);
}
break;
} /* end for loop */
+ db_unlock(jcr->db);
/*
* Send Find Media response to Storage daemon
&sdmr.VolWrites, &sdmr.MaxVolBytes, &sdmr.LastWritten, &sdmr.VolStatus,
&sdmr.Slot, &relabel) == 14) {
+ db_lock(jcr->db);
Dmsg3(400, "Update media %s oldStat=%s newStat=%s\n", sdmr.VolumeName,
mr.VolStatus, sdmr.VolStatus);
bstrncpy(mr.VolumeName, sdmr.VolumeName, sizeof(mr.VolumeName)); /* copy Volume name */
Jmsg(jcr, M_ERROR, 0, _("Unable to get Media record for Volume %s: ERR=%s\n"),
mr.VolumeName, db_strerror(jcr->db));
bnet_fsend(bs, "1991 Catalog Request failed: %s", db_strerror(jcr->db));
+ db_unlock(jcr->db);
return;
}
/* Set first written time if this is first job */
bnet_fsend(bs, "1992 Update Media error\n");
Dmsg0(190, "send error\n");
}
+ db_unlock(jcr->db);
/*
* Request to create a JobMedia record
jcr->stime[0] = 0;
since[0] = 0;
switch (jcr->JobLevel) {
- case L_DIFFERENTIAL:
- case L_INCREMENTAL:
- /* Look up start time of last job */
- jcr->jr.JobId = 0;
- if (!db_find_job_start_time(jcr, jcr->db, &jcr->jr, &jcr->stime)) {
- Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
- Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found. Doing FULL backup.\n"));
- bsnprintf(since, since_len, " (upgraded from %s)",
- level_to_str(jcr->JobLevel));
- jcr->JobLevel = jcr->jr.Level = L_FULL;
- } else {
- bstrncpy(since, ", since=", sizeof(since));
- bstrncat(since, jcr->stime, sizeof(since));
- }
- Dmsg1(115, "Last start time = %s\n", jcr->stime);
- break;
+ case L_DIFFERENTIAL:
+ case L_INCREMENTAL:
+ /* Look up start time of last job */
+ jcr->jr.JobId = 0;
+ if (!db_find_job_start_time(jcr, jcr->db, &jcr->jr, &jcr->stime)) {
+ Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
+ Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found. Doing FULL backup.\n"));
+ bsnprintf(since, since_len, " (upgraded from %s)",
+ level_to_str(jcr->JobLevel));
+ jcr->JobLevel = jcr->jr.Level = L_FULL;
+ } else {
+ bstrncpy(since, ", since=", since_len);
+ bstrncat(since, jcr->stime, since_len);
+ }
+ Dmsg1(115, "Last start time = %s\n", jcr->stime);
+ break;
}
}
}
fo = ie->opts_list[0];
for (int j=0; j<fo->match.size(); j++) {
- Dmsg1(000, "Match=%s\n", fo->match.get(j));
+ Dmsg1(100, "Match=%s\n", fo->match.get(j));
}
for (int j=0; j<ie->num_names; j++) {
p = ie->name_list[j];
extern int prunecmd(UAContext *ua, char *cmd);
extern int purgecmd(UAContext *ua, char *cmd);
extern int restorecmd(UAContext *ua, char *cmd);
-extern int labelcmd(UAContext *ua, char *cmd);
-extern int relabelcmd(UAContext *ua, char *cmd);
+extern int label_cmd(UAContext *ua, char *cmd);
+extern int relabel_cmd(UAContext *ua, char *cmd);
extern int update_slots(UAContext *ua); /* ua_label.c */
/* Forward referenced functions */
{ N_("estimate"), estimate_cmd, _("performs FileSet estimate debug=1 give full listing")},
{ N_("exit"), quit_cmd, _("exit = quit")},
{ N_("help"), help_cmd, _("print this command")},
- { N_("label"), labelcmd, _("label a tape")},
+ { N_("label"), label_cmd, _("label a tape")},
{ N_("list"), listcmd, _("list [pools | jobs | jobtotals | media <pool> | files job=<nn>]; from catalog")},
{ N_("llist"), llistcmd, _("full or long list like list command")},
{ N_("messages"), messagescmd, _("messages")},
{ N_("purge"), purgecmd, _("purge records from catalog")},
{ N_("query"), querycmd, _("query catalog")},
{ N_("quit"), quit_cmd, _("quit")},
- { N_("relabel"), relabelcmd, _("relabel a tape")},
+ { N_("relabel"), relabel_cmd, _("relabel a tape")},
{ N_("release"), release_cmd, _("release <storage-name>")},
{ N_("restore"), restorecmd, _("restore files")},
{ N_("run"), runcmd, _("run <job-name>")},
static void update_volretention(UAContext *ua, char *val, MEDIA_DBR *mr)
{
char ed1[50];
- POOLMEM *query = get_pool_memory(PM_MESSAGE);
+ POOLMEM *query;
if (!duration_to_utime(val, &mr->VolRetention)) {
- bsendmsg(ua, _("Invalid retention period specified.\n"));
+ bsendmsg(ua, _("Invalid retention period specified: %s\n"), val);
return;
}
+ query = get_pool_memory(PM_MESSAGE);
Mmsg(&query, "UPDATE Media SET VolRetention=%s WHERE MediaId=%u",
edit_uint64(mr->VolRetention, ed1), mr->MediaId);
if (!db_sql_query(ua->db, query, NULL, NULL)) {
static void update_voluseduration(UAContext *ua, char *val, MEDIA_DBR *mr)
{
char ed1[50];
- POOLMEM *query = get_pool_memory(PM_MESSAGE);
+ POOLMEM *query;
+
if (!duration_to_utime(val, &mr->VolUseDuration)) {
- bsendmsg(ua, _("Invalid use duration specified.\n"));
+ bsendmsg(ua, _("Invalid use duration specified: %s\n"), val);
return;
}
- query = get_pool_memory(PM_MESSAGE);
Mmsg(&query, "UPDATE Media SET VolUseDuration=%s WHERE MediaId=%u",
edit_uint64(mr->VolUseDuration, ed1), mr->MediaId);
if (!db_sql_query(ua->db, query, NULL, NULL)) {
{
uint64_t maxbytes;
char ed1[50];
- POOLMEM *query = get_pool_memory(PM_MESSAGE);
+ POOLMEM *query;
+
if (!size_to_uint64(val, strlen(val), &maxbytes)) {
- bsendmsg(ua, _("Invalid byte size specification.\n"));
+ bsendmsg(ua, _("Invalid max. bytes specification: %s\n"), val);
return;
}
+ query = get_pool_memory(PM_MESSAGE);
Mmsg(&query, "UPDATE Media SET MaxVolBytes=%s WHERE MediaId=%u",
edit_uint64(maxbytes, ed1), mr->MediaId);
if (!db_sql_query(ua->db, query, NULL, NULL)) {
static void update_volrecycle(UAContext *ua, char *val, MEDIA_DBR *mr)
{
int recycle;
- POOLMEM *query = get_pool_memory(PM_MESSAGE);
+ POOLMEM *query;
if (strcasecmp(val, _("yes")) == 0) {
recycle = 1;
} else if (strcasecmp(val, _("no")) == 0) {
bsendmsg(ua, _("Invalid value. It must by yes or no.\n"));
return;
}
+ query = get_pool_memory(PM_MESSAGE);
Mmsg(&query, "UPDATE Media SET Recycle=%d WHERE MediaId=%u",
recycle, mr->MediaId);
if (!db_sql_query(ua->db, query, NULL, NULL)) {
N_("VolUse"),
N_("MaxVolJobs"),
N_("MaxVolFiles"),
+ N_("MaxVolBytes"),
N_("Recycle"),
NULL };
return 0;
}
for (int i=0; kw[i]; i++) {
- if (find_arg_with_value(ua, kw[i]) > 0) {
+ int j;
+ if ((j=find_arg_with_value(ua, kw[i])) > 0) {
switch (i) {
case 0:
- update_volstatus(ua, ua->argv[i], &mr);
+ update_volstatus(ua, ua->argv[j], &mr);
+ break;
+ case 1:
+ update_volretention(ua, ua->argv[j], &mr);
+ break;
+ case 2:
+ update_voluseduration(ua, ua->argv[j], &mr);
+ break;
+ case 3:
+ update_volmaxjobs(ua, ua->argv[j], &mr);
+ break;
+ case 4:
+ update_volmaxfiles(ua, ua->argv[j], &mr);
+ break;
+ case 5:
+ update_volmaxbytes(ua, ua->argv[j], &mr);
+ break;
+ case 6:
+ update_volrecycle(ua, ua->argv[j], &mr);
break;
}
done = true;
*
* label storage=xxx volume=vvv
*/
-int labelcmd(UAContext *ua, char *cmd)
+int label_cmd(UAContext *ua, char *cmd)
{
return do_label(ua, cmd, 0); /* standard label */
}
-int relabelcmd(UAContext *ua, char *cmd)
+int relabel_cmd(UAContext *ua, char *cmd)
{
return do_label(ua, cmd, 1); /* relabel tape */
}
memset(&mr, 0, sizeof(mr));
bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName));
+ db_lock(ua->db);
if (db_get_media_record(ua->jcr, ua->db, &mr)) {
if (mr.Slot != vl->Slot) {
mr.Slot = vl->Slot;
bsendmsg(ua, _("Catalog record for Volume \"%s\" is up to date.\n"),
mr.VolumeName);
}
+ db_unlock(ua->db);
continue;
} else {
bsendmsg(ua, _("Record for Volume \"%s\" not found in catalog.\n"),
mr.VolumeName);
}
+ db_unlock(ua->db);
}
/* If relabel get name of Volume to relabel */
if (relabel) {
- /* Check for volume=OldVolume */
- i = find_arg_with_value(ua, "volume");
+ /* Check for oldvolume=name */
+ i = find_arg_with_value(ua, "oldvolume");
if (i >= 0) {
memset(&omr, 0, sizeof(omr));
bstrncpy(omr.VolumeName, ua->argv[i], sizeof(omr.VolumeName));
}
}
- /* Check for name=NewVolume */
- i = find_arg_with_value(ua, "name");
+ /* Check for volume=NewVolume */
+ i = find_arg_with_value(ua, "volume");
if (i >= 0) {
pm_strcpy(&ua->cmd, ua->argv[i]);
goto checkName;
N_("bootstrap"),
N_("replace"),
N_("when"),
+ N_("yes"), /* 11 -- see below */
NULL};
if (!open_db(ua)) {
Dmsg2(200, "Doing arg %d = %s\n", i, ua->argk[i]);
for (j=0; !found && kw[j]; j++) {
if (strcasecmp(ua->argk[i], _(kw[j])) == 0) {
- if (!ua->argv[i]) {
+ /* Note, yes has no value, so do not err */
+ if (!ua->argv[i] && j != 11 /*yes*/) {
bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]);
return 1;
}
when = ua->argv[i];
found = True;
break;
+ case 11: /* yes */
+ found = True;
+ break;
default:
break;
}
if (mod[i] == 0 || !is_a_number(str)) {
return 0;
}
+ errno = 0;
val = strtod(str, NULL);
if (errno != 0 || val < 0) {
return 0;
}
Dmsg3(400, "size str=:%s: %lf i=%d\n", str, strtod(str, NULL), i);
+ errno = 0;
value = strtod(str, NULL);
if (errno != 0 || value < 0) {
return 0;