]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/cats/cats.h
authorEric Bollengier <eric@baculasystems.com>
Mon, 11 May 2020 15:03:22 +0000 (17:03 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:17 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Apr 24 10:27:09 2020 +0200

    Add update jobid=x reviewed=y command

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Apr 24 20:16:22 2020 +0200

    Reliably log user activity in a way that satisfies auditors

    Messages {
      name = Standard
      append = /tmp/bacula.log = all

      # To send the events into a log and in the catalog
      append = /tmp/audit.log = events, !events.bweb
      catalog = all, events
    }

    Users can create custom events with a console command:

    .events

    They can list events in the catalog with

    * list events
    +---------------------+------------+-----------+--------------------------------+
    | time                | type       | source    | events                         |
    +---------------------+------------+-----------+--------------------------------+
    | 2020-04-24 17:04:07 | daemon     | *Daemon*  | Director startup               |
    | 2020-04-24 17:04:12 | connection | *Console* | Connection from 127.0.0.1:8101 |
    | 2020-04-24 17:04:20 | command    | *Console* | purge jobid=1                  |
    +---------------------+------------+-----------+--------------------------------+

    The event format in the log is:

    24-Apr 17:04 Events: code=DC0001 from=zog8-dir ref=0x1fa5 type=daemon source=*Daemon* text=Director startup

    24-Apr 17:04 Events: code=DC0002 from=zog8-dir ref=0x7fb58000c4b8 type=connection source=*Console* text=Connection from 127.0.0.1:8101

    The reference (ref) is used to identify a console session, all activity
    from the same console will have the same reference.

    The source is the name of the restricted console, or *Console* if this
    is the default console.

    We have the following events:
     - cancel a job
     - delete volume
     - delete job
     - purge job
     - delete pool
     - delete client
     - daemon startup
     - daemon shutdown
     - console connection
     - console disconnection

    To add a new events:
    ua->send_events(type, format, arguments);

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Dec 14 10:16:15 2018 +0100

    Add update command to set the Job comment field

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Wed Dec 12 11:22:37 2018 +0100

    Use bmemset() rather than memset() in POOL_DBR creation

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Feb 13 14:13:54 2018 +0100

    Add Pool::MaxPoolBytes to the catalog. Catalog version is now 1020

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Mon Aug 28 16:46:19 2017 +0200

    Add SQL functions to list RestoreObjects and files

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Apr 5 18:55:10 2016 +0200

    Implement FileMedia feature and FO_OFFSETS for plugin

     - Allow plugins to use the FO_OFFSETS option
     - Add SQL support in cats
     - Add bvfs commands
     - Add FileMedia handling in the Storage Daemon
     - Add use FO_OFFSETS option in test plugin
     - Add new sql scripts to configure.in
     - Update catalog version to 1018

Author: Kern Sibbald <kern@sibbald.com>
Date:   Tue Feb 25 22:46:38 2014 +0100

    Minor cleanup/refactor of cats

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Mon Aug 26 13:57:34 2013 +0200

    Merge Filename table to File

bacula/src/cats/cats.h

index c260c25a1dd367ff980d646681c819df8d9dc49a..60e15bc47ccf943424d98950e092e371ca3b9ce8 100644 (file)
@@ -48,7 +48,7 @@
  */
 
 /* Current database version number for all drivers */
-#define BDB_VERSION 16
+#define BDB_VERSION 1022
 
 typedef void (DB_LIST_HANDLER)(void *, const char *);
 typedef int (DB_RESULT_HANDLER)(void *, int, char **);
@@ -65,7 +65,8 @@ typedef enum {
 typedef enum {
    SQL_DRIVER_TYPE_MYSQL      = 0,
    SQL_DRIVER_TYPE_POSTGRESQL = 1,
-   SQL_DRIVER_TYPE_SQLITE3    = 2
+   SQL_DRIVER_TYPE_SQLITE3    = 2,
+   SQL_DRIVER_TYPE_DBI        = 3
 } SQL_DRIVER;
 
 
@@ -122,6 +123,7 @@ struct JOB_DBR {
    char Job[MAX_NAME_LENGTH];         /* Job unique name */
    char Name[MAX_NAME_LENGTH];        /* Job base name */
    char PriorJob[MAX_NAME_LENGTH];    /* PriorJob name if any */
+   char Comment[MAX_NAME_LENGTH];     /* Comment */
    int JobType;                       /* actually char(1) */
    int JobLevel;                      /* actually char(1) */
    int JobStatus;                     /* actually char(1) */
@@ -143,6 +145,7 @@ struct JOB_DBR {
    uint64_t ReadBytes;
    int PurgedFiles;
    int HasBase;
+   int Reviewed;
 
    /* Note, FirstIndex, LastIndex, Start/End File and Block
     * are only used in the JobMedia record.
@@ -187,6 +190,18 @@ struct JOBMEDIA_DBR {
 };
 
 
+/* File Media information used to create the file media records
+ * for each file indexed in a volume
+ */
+struct FILEMEDIA_DBR {
+   JobId_t  JobId;                    /* JobId */
+   DBId_t MediaId;                    /* MediaId */
+   uint32_t FileIndex;                /* File index in the job */
+   uint32_t RecordNo;                 /* Record number in the block */
+   uint64_t BlockAddress;             /* Address of the block on the volume */
+   uint64_t FileOffset;               /* Offset in the file */
+};
+
 /* Volume Parameter structure */
 struct VOL_PARAMS {
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
@@ -217,7 +232,7 @@ struct ATTR_DBR {
    JobId_t  JobId;
    DBId_t ClientId;
    DBId_t PathId;
-   DBId_t FilenameId;
+   char *Filename;
    FileId_t FileId;
    char *Digest;
    int DigestType;
@@ -237,6 +252,8 @@ struct ROBJECT_DBR {
    uint32_t FileType;
    JobId_t  JobId;
    DBId_t RestoreObjectId;
+
+   int limit;                   /* Needed to restrict a search */
 };
 
 
@@ -246,7 +263,7 @@ struct FILE_DBR {
    int32_t FileIndex;
    int32_t FileIndex2;
    JobId_t  JobId;
-   DBId_t FilenameId;
+   char *Filename;              /* Need external storage, should be escaped */
    DBId_t PathId;
    JobId_t  MarkId;
    uint32_t DeltaSeq;
@@ -258,12 +275,9 @@ struct FILE_DBR {
 /* Pool record -- same format as database */
 class POOL_DBR {
 public:
-   /*
-    * Do not turn on constructor until all bmemset on POOL_DBR removed
-    *
-    * POOL_DBR() { bmemset(this, 0, sizeof(POOL_DBR)); };
-    * ~POOL_DBR() {  };
-    */
+   POOL_DBR() { bmemset(this, 0, sizeof(POOL_DBR)); };
+   ~POOL_DBR() {  };
+
    DBId_t PoolId;
    char Name[MAX_NAME_LENGTH];        /* Pool name */
    uint32_t NumVols;                  /* total number of volumes */
@@ -281,12 +295,14 @@ public:
    uint32_t MaxVolJobs;               /* Max Jobs on Volume */
    uint32_t MaxVolFiles;              /* Max files on Volume */
    uint64_t MaxVolBytes;              /* Max bytes on Volume */
+   uint64_t MaxPoolBytes;             /* Maximum Pool size */
    DBId_t RecyclePoolId;              /* RecyclePool destination when media is purged */
    DBId_t ScratchPoolId;              /* ScratchPool source when media is needed */
    char PoolType[MAX_NAME_LENGTH];
    char LabelFormat[MAX_NAME_LENGTH];
    /* Extra stuff not in DB */
    faddr_t rec_addr;
+   uint64_t PoolBytes;            /* Updated after db_get_pool_numvols() */
 };
 
 class DEVICE_DBR {
@@ -614,6 +630,7 @@ public:
    }
 };
 
+
 /* Functions exported by sql.c for use within the cats directory. */
 int list_result(void *vctx, int cols, char **row);
 int list_result(JCR *jcr, BDB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type);