]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_dotcmds.c
- Move test for MaxStartDelay as suggested by Peter.
[bacula/bacula] / bacula / src / dird / ua_dotcmds.c
index c6cc6120ac28641d05c99521af291770eeb619d9..e2be84ffc0b67941e1daa1f1391bd354ad33d961 100644 (file)
@@ -39,10 +39,13 @@ extern int r_first;
 extern int r_last;
 extern struct s_res resources[];
 extern char my_name[];
+extern const char *client_backups;
 
 /* Imported functions */
 extern int qmessagescmd(UAContext *ua, const char *cmd);
 extern int quit_cmd(UAContext *ua, const char *cmd);
+extern int qhelp_cmd(UAContext *ua, const char *cmd);
+extern int qstatus_cmd(UAContext *ua, const char *cmd);
 
 /* Forward referenced functions */
 static int diecmd(UAContext *ua, const char *cmd);
@@ -54,9 +57,10 @@ static int poolscmd(UAContext *ua, const char *cmd);
 static int storagecmd(UAContext *ua, const char *cmd);
 static int defaultscmd(UAContext *ua, const char *cmd);
 static int typescmd(UAContext *ua, const char *cmd);
+static int backupscmd(UAContext *ua, const char *cmd);
 static int levelscmd(UAContext *ua, const char *cmd);
 
-struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; 
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; };
 static struct cmdstruct commands[] = {
  { N_(".die"),        diecmd,       NULL},
  { N_(".jobs"),       jobscmd,      NULL},
@@ -65,12 +69,15 @@ static struct cmdstruct commands[] = {
  { N_(".msgs"),       msgscmd,      NULL},
  { N_(".pools"),      poolscmd,     NULL},
  { N_(".types"),      typescmd,     NULL},
+ { N_(".backups"),    backupscmd,   NULL},
  { N_(".levels"),     levelscmd,    NULL},
+ { N_(".status"),     qstatus_cmd,  NULL},
  { N_(".storage"),    storagecmd,   NULL},
  { N_(".defaults"),   defaultscmd,  NULL},
  { N_(".messages"),   qmessagescmd, NULL},
+ { N_(".help"),       qhelp_cmd,    NULL},
  { N_(".quit"),       quit_cmd,     NULL},
- { N_(".exit"),       quit_cmd,     NULL} 
+ { N_(".exit"),       quit_cmd,     NULL}
             };
 #define comsize (sizeof(commands)/sizeof(struct cmdstruct))
 
@@ -80,12 +87,12 @@ static struct cmdstruct commands[] = {
 int do_a_dot_command(UAContext *ua, const char *cmd)
 {
    int i;
-   int len, stat;  
+   int len, stat;
    bool found = false;
 
    stat = 1;
 
-   Dmsg1(400, "Dot command: %s\n", ua->UA_sock->msg);
+   Dmsg1(1400, "Dot command: %s\n", ua->UA_sock->msg);
    if (ua->argc == 0) {
       return 1;
    }
@@ -102,7 +109,7 @@ int do_a_dot_command(UAContext *ua, const char *cmd)
       }
    }
    if (!found) {
-      pm_strcat(&ua->UA_sock->msg, _(": is an illegal command\n"));
+      pm_strcat(ua->UA_sock->msg, _(": is an illegal command\n"));
       ua->UA_sock->msglen = strlen(ua->UA_sock->msg);
       bnet_send(ua->UA_sock);
    }
@@ -110,13 +117,13 @@ int do_a_dot_command(UAContext *ua, const char *cmd)
 }
 
 /*
- * Create segmentation fault 
+ * Create segmentation fault
  */
 static int diecmd(UAContext *ua, const char *cmd)
 {
    JCR *jcr = NULL;
    int a;
-   
+
    bsendmsg(ua, "The Director will segment fault.\n");
    a = jcr->JobId; /* ref NULL pointer */
    jcr->JobId = 1000; /* another ref NULL pointer */
@@ -199,6 +206,31 @@ static int typescmd(UAContext *ua, const char *cmd)
    return 1;
 }
 
+static int client_backups_handler(void *ctx, int num_field, char **row)
+{
+   UAContext *ua = (UAContext *)ctx;
+   bsendmsg(ua, "| %s | %s | %s | %s | %s | %s | %s |\n",
+      row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]);
+   return 0;
+}
+
+static int backupscmd(UAContext *ua, const char *cmd)
+{
+   if (!open_db(ua)) {
+      return 1;
+   }
+   if (ua->argc == 2 && strcmp(ua->argk[1], "client") != 0) {
+      return 1;
+   }
+   Mmsg(ua->cmd, client_backups, ua->argv[1]);
+   if (!db_sql_query(ua->db, ua->cmd, client_backups_handler, (void *)ua)) {
+      bsendmsg(ua, _("Query failed: %s. ERR=%s\n"), ua->cmd, db_strerror(ua->db));
+      return 1;
+   }
+   return 1;
+}
+
+
 static int levelscmd(UAContext *ua, const char *cmd)
 {
    bsendmsg(ua, "Incremental\n");
@@ -217,17 +249,19 @@ static int levelscmd(UAContext *ua, const char *cmd)
  */
 static int defaultscmd(UAContext *ua, const char *cmd)
 {
-   JOB *job;      
+   JOB *job;
    if (ua->argc == 2 && strcmp(ua->argk[1], "job") == 0) {
       job = (JOB *)GetResWithName(R_JOB, ua->argv[1]);
       if (job) {
+        STORE *store;
          bsendmsg(ua, "job=%s", job->hdr.name);
          bsendmsg(ua, "pool=%s", job->pool->hdr.name);
          bsendmsg(ua, "messages=%s", job->messages->hdr.name);
          bsendmsg(ua, "client=%s", job->client->hdr.name);
-         bsendmsg(ua, "storage=%s", job->storage->hdr.name);
+        store = (STORE *)job->storage->first();
+         bsendmsg(ua, "storage=%s", store->hdr.name);
          bsendmsg(ua, "where=%s", job->RestoreWhere?job->RestoreWhere:"");
-         bsendmsg(ua, "level=%s", level_to_str(job->level));
+         bsendmsg(ua, "level=%s", level_to_str(job->JobLevel));
          bsendmsg(ua, "type=%s", job_type_to_str(job->JobType));
          bsendmsg(ua, "fileset=%s", job->fileset->hdr.name);
       }