From: Alain Spineux Date: Fri, 2 Sep 2022 09:33:50 +0000 (+0200) Subject: make snapshots works on sqlite X-Git-Tag: Beta-15.0.0~451 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9943e177b7c40a7014de580ca507dccb18ec01d4;p=thirdparty%2Fbacula.git make snapshots works on sqlite - 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 --- diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index 29c774a2f..f128456ba 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -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); diff --git a/bacula/src/dird/snapshot.c b/bacula/src/dird/snapshot.c index 0b974ddd6..5d2cfb6e0 100644 --- a/bacula/src/dird/snapshot.c +++ b/bacula/src/dird/snapshot.c @@ -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)); } }