#!/bin/sh
#
# shell script to create Bacula SQLite tables
+#
+# Copyright (C) 2000-2017 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
-bindir=@SQL_BINDIR@
+bindir=@SQLITE_BINDIR@
PATH="$bindir:$PATH"
cd @working_dir@
-sqlite=@DB_TYPE@
db_name=@db_name@
-${sqlite} $* ${db_name}.db <<END-OF-DATA
+sqlite3 $* ${db_name}.db <<END-OF-DATA
CREATE TABLE Filename (
FilenameId INTEGER,
Name TEXT DEFAULT '',
JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
PathId INTEGER UNSIGNED REFERENCES Path NOT NULL,
FilenameId INTEGER UNSIGNED REFERENCES Filename NOT NULL,
+ DeltaSeq SMALLINT UNSIGNED DEFAULT 0,
MarkId INTEGER UNSIGNED DEFAULT 0,
LStat VARCHAR(255) NOT NULL,
MD5 VARCHAR(255) NOT NULL,
RestoreObject TEXT DEFAULT '',
PluginName TEXT DEFAULT '',
ObjectLength INTEGER DEFAULT 0,
+ ObjectFullLength INTEGER DEFAULT 0,
ObjectIndex INTEGER DEFAULT 0,
ObjectType INTEGER DEFAULT 0,
FileIndex INTEGER UNSIGNED DEFAULT 0,
- ObejctCompression INTEGER DEFAULT 0,
+ ObjectCompression INTEGER DEFAULT 0,
JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
PRIMARY KEY(RestoreObjectId)
);
HasCache TINYINT DEFAULT 0,
Reviewed TINYINT DEFAULT 0,
Comment TEXT,
+ FileTable TEXT DEFAULT 'File',
PRIMARY KEY(JobId)
);
CREATE INDEX inx6 ON Job (Name);
+CREATE INDEX job_jobtdate_inx ON Job (JobTDate);
-- Create a table like Job for long term statistics
CREATE TABLE JobHisto (
HasBase TINYINT DEFAULT 0,
HasCache TINYINT DEFAULT 0,
Reviewed TINYINT DEFAULT 0,
- Comment TEXT
+ Comment TEXT,
+ FileTable TEXT DEFAULT 'File'
);
CREATE INDEX inx61 ON JobHisto (StartTime);
VolJobs INTEGER UNSIGNED DEFAULT 0,
VolFiles INTEGER UNSIGNED DEFAULT 0,
VolBlocks INTEGER UNSIGNED DEFAULT 0,
+ LastPartBytes BIGINT UNSIGNED DEFAULT 0,
VolMounts INTEGER UNSIGNED DEFAULT 0,
VolBytes BIGINT UNSIGNED DEFAULT 0,
- VolParts INTEGER UNSIGNED DEFAULT 0,
+ VolABytes BIGINT UNSIGNED DEFAULT 0,
+ VolAPadding BIGINT UNSIGNED DEFAULT 0,
+ VolHoleBytes BIGINT UNSIGNED DEFAULT 0,
+ VolHoles INTEGER UNSIGNED DEFAULT 0,
+ VolType INTEGER UNSIGNED DEFAULT 0,
+ VolParts INTERGER UNSIGNED DEFAULT 0,
+ VolCloudParts INTERGER UNSIGNED DEFAULT 0,
VolErrors INTEGER UNSIGNED DEFAULT 0,
- VolWrites INTEGER UNSIGNED DEFAULT 0,
+ VolWrites BIGINT UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
ActionOnPurge TINYINT DEFAULT 0,
+ CacheRetention BIGINT UNSIGNED DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
);
CREATE INDEX inx8 ON Media (PoolId);
+CREATE INDEX inx9 ON Media (StorageId);
+
CREATE TABLE MediaType (
MediaTypeId INTEGER,
UseOnce TINYINT DEFAULT 0,
UseCatalog TINYINT DEFAULT 1,
AcceptAnyVolume TINYINT DEFAULT 0,
+ CacheRetention BIGINT UNSIGNED DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
);
CREATE TABLE BaseFiles (
- BaseId INTEGER,
+ BaseId BIGINT,
BaseJobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
FileId INTEGER UNSIGNED REFERENCES File NOT NULL,
CREATE INDEX pathvisibility_jobid
ON PathVisibility (JobId);
+
+CREATE TABLE Snapshot (
+ SnapshotId serial,
+ Name text NOT NULL,
+ JobId integer default 0,
+ FileSetId integer default 0,
+ CreateTDate bigint default 0,
+ CreateDate datetime not null,
+ ClientId int default 0,
+ Volume text not null,
+ Device text not null,
+ Type text not null,
+ Retention int default 0,
+ Comment text,
+ primary key (SnapshotId)
+);
+
+CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device, Volume, Name);
+
CREATE TABLE Status (
JobStatus CHAR(1) NOT NULL,
JobStatusLong BLOB,
('a', 'SD despooling attributes',15);
INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
('i', 'Doing batch insert file records',15);
-
+INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
+ ('I', 'Incomplete Job',25);
-- Initialize Version
-INSERT INTO Version (VersionId) VALUES (12);
-
+INSERT INTO Version (VersionId) VALUES (15);
PRAGMA default_cache_size = 100000;
PRAGMA synchronous = NORMAL;