]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/backup.c
03Dec05
[bacula/bacula] / bacula / src / dird / backup.c
index 39f9ce56d5c4d5b61dd89a2b6c583cd48c4b4a49..f10207a158c8f9d641f94850b829c08371e9cf6b 100644 (file)
  *
  *   Version $Id$
  */
-
 /*
    Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   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 along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -54,10 +48,19 @@ static char EndJob[]     = "2800 End Job TermCode=%d JobFiles=%u "
  */
 bool do_backup_init(JCR *jcr)
 {
-   FILESET_DBR fsr;
    POOL_DBR pr;
+
+   if (!get_or_create_fileset_record(jcr)) {
+      return false;
+   }
+
+   /* 
+    * Get definitive Job level and since time
+    */
+   get_level_since_time(jcr, jcr->since, sizeof(jcr->since));
+
    /*
-    * Get the Pool record -- first apply any level defined pools
+    * Apply any level related Pool selections
     */
    switch (jcr->JobLevel) {
    case L_FULL:
@@ -97,13 +100,6 @@ bool do_backup_init(JCR *jcr)
    jcr->PoolId = pr.PoolId;               /****FIXME**** this can go away */
    jcr->jr.PoolId = pr.PoolId;
 
-   if (!get_or_create_fileset_record(jcr, &fsr)) {
-      return false;
-   }
-   bstrncpy(jcr->FSCreateTime, fsr.cCreateTime, sizeof(jcr->FSCreateTime));
-
-   get_level_since_time(jcr, jcr->since, sizeof(jcr->since));
-
    Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->cloned, jcr->job->run_cmds);
    if (!jcr->cloned && jcr->job->run_cmds) {
       char *runcmd;
@@ -142,11 +138,12 @@ bool do_backup(JCR *jcr)
    int tls_need = BNET_TLS_NONE;
    BSOCK   *fd;
    STORE *store;
+   char ed1[100];
 
 
    /* Print Job Start message */
-   Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %u, Job=%s\n"),
-        jcr->JobId, jcr->Job);
+   Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %s, Job=%s\n"),
+        edit_uint64(jcr->JobId, ed1), jcr->Job);
 
    set_jcr_job_status(jcr, JS_Running);
    Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel);
@@ -172,11 +169,14 @@ bool do_backup(JCR *jcr)
    /*
     * Now start a job with the Storage daemon
     */
-   if (!start_storage_daemon_job(jcr, jcr->storage, SD_APPEND)) {
+   if (!start_storage_daemon_job(jcr, NULL, jcr->storage)) {
       return false;
    }
    /*
-    * Now start a Storage daemon message thread
+    * Now start a Storage daemon message thread.  Note,
+    *   this thread is used to provide the catalog services
+    *   for the backup job, including inserting the attributes
+    *   into the catalog.  See catalog_update() in catreq.c
     */
    if (!start_storage_daemon_message_thread(jcr)) {
       return false;
@@ -211,7 +211,6 @@ bool do_backup(JCR *jcr)
       store->SDDport = store->SDport;
    }
 
-#ifdef HAVE_TLS
    /* TLS Requirement */
    if (store->tls_enable) {
       if (store->tls_require) {
@@ -220,7 +219,6 @@ bool do_backup(JCR *jcr)
          tls_need = BNET_TLS_OK;
       }
    }
-#endif
 
    bnet_fsend(fd, storaddr, store->address, store->SDDport,
               tls_need);
@@ -326,12 +324,14 @@ void backup_cleanup(JCR *jcr, int TermCode)
    const char *term_msg;
    int msg_type;
    MEDIA_DBR mr;
+   CLIENT_DBR cr;
    double kbps, compression;
    utime_t RunTime;
 
    Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode);
    dequeue_messages(jcr);             /* display any queued messages */
    memset(&mr, 0, sizeof(mr));
+   memset(&cr, 0, sizeof(cr));
    set_jcr_job_status(jcr, TermCode);
 
    update_job_end_record(jcr);        /* update database */
@@ -342,6 +342,12 @@ void backup_cleanup(JCR *jcr, int TermCode)
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
 
+   bstrncpy(cr.Name, jcr->client->hdr.name, sizeof(cr.Name));
+   if (!db_get_client_record(jcr, jcr->db, &cr)) {
+      Jmsg(jcr, M_WARNING, 0, _("Error getting client record for stats: %s"),
+         db_strerror(jcr->db));
+   }
+
    bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName));
    if (!db_get_media_record(jcr, jcr->db, &mr)) {
       Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
@@ -379,6 +385,10 @@ void backup_cleanup(JCR *jcr, int TermCode)
              }
 
          }
+         /* Start output with when and who wrote it */
+         bstrftimes(edt, sizeof(edt), time(NULL));
+         fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->jr.Job,
+                 level_to_str(jcr->JobLevel), jcr->since);
          for (int i=0; i < VolCount; i++) {
             /* Write the record */
             fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
@@ -479,11 +489,11 @@ void backup_cleanup(JCR *jcr, int TermCode)
 
 // bmicrosleep(15, 0);                /* for debugging SIGHUP */
 
-   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+   Jmsg(jcr, msg_type, 0, _("Bacula %s (%s): %s\n"
 "  JobId:                  %d\n"
 "  Job:                    %s\n"
 "  Backup Level:           %s%s\n"
-"  Client:                 %s\n"
+"  Client:                 \"%s\" %s\n"
 "  FileSet:                \"%s\" %s\n"
 "  Pool:                   \"%s\"\n"
 "  Storage:                \"%s\"\n"
@@ -506,11 +516,13 @@ void backup_cleanup(JCR *jcr, int TermCode)
 "  FD termination status:  %s\n"
 "  SD termination status:  %s\n"
 "  Termination:            %s\n\n"),
+        VERSION,
+        LSMDATE,
         edt,
         jcr->jr.JobId,
         jcr->jr.Job,
         level_to_str(jcr->JobLevel), jcr->since,
-        jcr->client->hdr.name,
+        jcr->client->hdr.name, cr.Uname,
         jcr->fileset->hdr.name, jcr->FSCreateTime,
         jcr->pool->hdr.name,
         jcr->store->hdr.name,