]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
make snapshots works on sqlite
authorAlain Spineux <alain@baculasystems.com>
Fri, 2 Sep 2022 09:33:50 +0000 (11:33 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:59 +0000 (13:56 +0200)
- the goal is to make tests/snapshot-lvm-test works
- there is some difference on the DB side :
  - serial and bigserial don't exist in Sqlite, instead use
    INTEGER PRIMARY KEY AUTOINCREMENT
  - the row title for sqlite is SnapshotId vs snapshotid for pgsql

bacula/src/cats/make_sqlite3_tables.in
bacula/src/dird/snapshot.c

index 29c774a2f9f4f1dfac7726e61b008e93a092845d..f128456baf3be611c0c1ed248be8ff0f050784b7 100644 (file)
@@ -28,7 +28,7 @@ CREATE INDEX malwaresha256_idx on MalwareSHA256 (MD5);
 
 CREATE TABLE FileEvents 
 (
-   Id   bigserial,
+   Id    INTEGER PRIMARY KEY AUTOINCREMENT,
    Time  DATETIME DEFAULT current_timestamp, -- Time of the detection
    SourceJobId   int,        -- Can be the Verify job id for example, or the jobid during a restore/backup
    JobId         int,        -- JobId where the file was found. Used for pruning
@@ -576,7 +576,7 @@ CREATE INDEX pathvisibility_jobid
 
 
 CREATE TABLE Snapshot (
-  SnapshotId     serial,
+  SnapshotId     INTEGER PRIMARY KEY AUTOINCREMENT,
   Name           text NOT NULL,
   JobId          integer default 0,
   FileSetId      integer default 0,
@@ -587,8 +587,7 @@ CREATE TABLE Snapshot (
   Device         text not null,
   Type           text not null,
   Retention      int default 0,
-  Comment        text,
-  primary key (SnapshotId)
+  Comment        text
 );
 
 CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device, Volume, Name);
index 0b974ddd6b743d1ad46971d4caaa61c479fe7e8e..5d2cfb6e05d4134f95afc529fd8a12d729e15ae7 100644 (file)
@@ -274,7 +274,8 @@ static void storeit(void *ctx, const char *msg)
 {
    char ed1[51];
    alist *lst = (alist *)ctx;
-   if (sscanf(msg, "snapshotid=%50s", ed1) == 1) {
+   if (   sscanf(msg, "snapshotid=%50s", ed1) == 1
+       || sscanf(msg, "SnapshotId=%50s", ed1) == 1) {
       lst->append((void *)(intptr_t) str_to_int64(ed1));
    }
 }