From a5a71770d2b43ff3749dc1da2082940cfb41770a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 28 Nov 2003 18:25:45 +0000 Subject: [PATCH] Fix update catalog problems + Mark bscan Vols as Archive git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@817 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/configure.in | 3 +- bacula/configure | 3 +- bacula/kernstodo | 12 ++-- bacula/src/cats/make_mysql_tables.in | 5 +- bacula/src/cats/make_sqlite_tables.in | 3 + bacula/src/cats/update_mysql_tables.in | 3 + bacula/src/cats/update_sqlite_tables.in | 95 ++++++++++++++++++++++++- bacula/src/stored/bacula-sd.conf.in | 2 + bacula/src/stored/bscan.c | 3 +- 9 files changed, 118 insertions(+), 11 deletions(-) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 91207688a1..b5b9052e1b 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1551,9 +1551,10 @@ chmod 755 src/cats/create_mysql_database chmod 755 src/cats/make_catalog_backup src/cats/delete_catalog_backup chmod 755 src/cats/grant_mysql_privileges chmod 755 src/cats/make_sqlite_tables src/cats/drop_sqlite_tables +chmod 755 src/cats/update_sqlite_tables chmod 755 src/cats/make_bacula_tables src/cats/drop_bacula_tables +chmod 755 src/cats/update_mysql_tables chmod 755 src/cats/update_bacula_tables src/cats/update_mysql_tables -chmod 755 src/cats/update/mysql_tables chmod 755 src/cats/create_sqlite_database chmod 755 src/cats/sqlite chmod 755 src/cats/make_bdb_tables src/cats/drop_bdb_tables diff --git a/bacula/configure b/bacula/configure index 258c1663fa..7765f5ec8b 100755 --- a/bacula/configure +++ b/bacula/configure @@ -18940,9 +18940,10 @@ chmod 755 src/cats/create_mysql_database chmod 755 src/cats/make_catalog_backup src/cats/delete_catalog_backup chmod 755 src/cats/grant_mysql_privileges chmod 755 src/cats/make_sqlite_tables src/cats/drop_sqlite_tables +chmod 755 src/cats/update_sqlite_tables chmod 755 src/cats/make_bacula_tables src/cats/drop_bacula_tables +chmod 755 src/cats/update_mysql_tables chmod 755 src/cats/update_bacula_tables src/cats/update_mysql_tables -chmod 755 src/cats/update/mysql_tables chmod 755 src/cats/create_sqlite_database chmod 755 src/cats/sqlite chmod 755 src/cats/make_bdb_tables src/cats/drop_bdb_tables diff --git a/bacula/kernstodo b/bacula/kernstodo index 8aa46fd83c..c3f3736f24 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -56,9 +56,10 @@ For 1.33 Testing/Documentation: - Setup a standard job that builds a bootstrap file and saves it with the catalog database. - Document Dan's new --with-dir-user, ... options. +- Document estimate command in tree. +- Document lsmark command in tree. For 1.33 -- Change "create_media_record in bscan to use Archive instead of Full. - Implement RestoreJobRetention? Maybe better "JobRetention" in a Job, which would take precidence over the Catalog "JobRetention". - Implement Label Format in Add and Label console commands. @@ -78,7 +79,6 @@ After 1.33: - Create VolAddr for disk files in place of VolFile and VolBlock. This is needed to properly specify ranges. - Print bsmtp output to job report so that problems will be seen. -- Have some way to estimate the restore size or have it printed. - Pass the number of files to be restored to the FD for reporting - Add progress of files/bytes to SD and FD. - Don't continue Restore if no files selected. @@ -87,9 +87,6 @@ After 1.33: - Add a date and time stamp at the beginning of every line in the Job report (Volker Sauer). - Client does not show busy during Estimate command. -- Volume problems occurs if you have valid volume, written, then it is - truncated. You get 12-Nov-2003 11:48 rufus-sd: kernsave.2003-11-12_11.48.09 Warning: mount.c:228 Volume on /tmp is not a Bacula labeled Volume, because: - block.c:640 Read zero bytes on device /tmp. - Implement Console mtx commands. - Look at 2Gb limit for SQLite. - Implement 3 Pools for a Job: @@ -935,4 +932,9 @@ Done: (see kernsdone for more) - Make mark/unmark report how many files marked/unmarked. - Keep last 5 or 10 completed jobs and show them in a similar list. - Make a Running Jobs: output similar to current Scheduled Jobs: +- Change "create_media_record in bscan to use Archive instead of Full. +- Have some way to estimate the restore size or have it printed. +- Volume problems occurs if you have valid volume, written, then it is + truncated. You get 12-Nov-2003 11:48 rufus-sd: kernsave.2003-11-12_11.48.09 Warning: mount.c:228 Volume on /tmp is not a Bacula labeled Volume, because: + block.c:640 Read zero bytes on device /tmp. diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 218f0b3c0f..9c0b5f8166 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -135,8 +135,11 @@ CREATE TABLE Pool ( MaxVolBytes BIGINT UNSIGNED NOT NULL, AutoPrune TINYINT DEFAULT 0, Recycle TINYINT DEFAULT 0, - PoolType ENUM('Backup', 'Copy', 'Cloned', 'Archive', 'Migration') NOT NULL, + PoolType ENUM('Backup', 'Copy', 'Cloned', 'Archive', 'Migration', 'Scratch') NOT NULL, LabelFormat TINYBLOB, + Enabled TINYINT DEFAULT 1, + ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, UNIQUE (Name(128)), PRIMARY KEY (PoolId) ); diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index c948ee2ce1..ed961d9a2a 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -139,6 +139,9 @@ CREATE TABLE Pool ( Recycle TINYINT DEFAULT 0, PoolType VARCHAR(20) NOT NULL, LabelFormat VARCHAR(128) NOT NULL, + Enabled TINYINT DEFAULT 1, + ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, UNIQUE (Name), PRIMARY KEY (PoolId) ); diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index 84bc568860..9da912da98 100755 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -14,6 +14,9 @@ USE bacula; ALTER TABLE Media ADD COLUMN Drive INTEGER NOT NULL DEFAULT 0; ALTER TABLE Media ADD COLUMN InChanger TINYINT NOT NULL DEFAULT 0; +ALTER TABLE Pool ADD COLUMN Enabled TINYINT DEFAULT 1; +ALTER TABLE Pool ADD COLUMN ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool; +ALTER TABLE Pool ADD COLUMN RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool; DROP TABLE BaseFiles; diff --git a/bacula/src/cats/update_sqlite_tables.in b/bacula/src/cats/update_sqlite_tables.in index ef75bc3e61..bb83b4f85c 100755 --- a/bacula/src/cats/update_sqlite_tables.in +++ b/bacula/src/cats/update_sqlite_tables.in @@ -49,7 +49,7 @@ INSERT INTO Media_backup SELECT VolMounts, VolBytes, VolErrors, VolWrites, VolCapacityBytes, VolStatus, Recycle, VolRetention, VolUseDuration, MaxVolJobs, - MaxVolFiles, MaxVolBytes + MaxVolFiles, MaxVolBytes, 0, 0 FROM Media; @@ -91,13 +91,104 @@ INSERT INTO Media ( VolMounts, VolBytes, VolErrors, VolWrites, VolCapacityBytes, VolStatus, Recycle, VolRetention, VolUseDuration, MaxVolJobs, - MaxVolFiles, MaxVolBytes) + MaxVolFiles, MaxVolBytes, Drive, InChanger) SELECT * FROM Media_backup; DROP TABLE Media_backup; CREATE INDEX inx8 ON Media (PoolId); +CREATE TABLE Pool_backup ( + PoolId INTEGER UNSIGNED AUTOINCREMENT, + Name VARCHAR(128) NOT NULL, + NumVols INTEGER UNSIGNED DEFAULT 0, + MaxVols INTEGER UNSIGNED DEFAULT 0, + UseOnce TINYINT DEFAULT 0, + UseCatalog TINYINT DEFAULT 1, + AcceptAnyVolume TINYINT DEFAULT 0, + VolRetention BIGINT UNSIGNED DEFAULT 0, + VolUseDuration BIGINT UNSIGNED DEFAULT 0, + MaxVolJobs INTEGER UNSIGNED DEFAULT 0, + MaxVolFiles INTEGER UNSIGNED DEFAULT 0, + MaxVolBytes BIGINT UNSIGNED DEFAULT 0, + AutoPrune TINYINT DEFAULT 0, + Recycle TINYINT DEFAULT 0, + PoolType VARCHAR(20) NOT NULL, + LabelFormat VARCHAR(128) NOT NULL, + Enabled TINYINT DEFAULT 1, + ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + UNIQUE (Name), + PRIMARY KEY (PoolId) + ); + +INSERT INTO Pool_backup SELECT + PoolId, + Name, + NumVols, + MaxVols, + UseOnce, + UseCatalog, + AcceptAnyVolume, + VolRetention, + VolUseDuration, + MaxVolJobs, + MaxVolFiles, + MaxVolBytes, + AutoPrune, + Recycle, + PoolType, + LabelFormat, 1, 0, 0 + FROM Pool; + +DROP TABLE Pool; + +CREATE TABLE Pool ( + PoolId INTEGER UNSIGNED AUTOINCREMENT, + Name VARCHAR(128) NOT NULL, + NumVols INTEGER UNSIGNED DEFAULT 0, + MaxVols INTEGER UNSIGNED DEFAULT 0, + UseOnce TINYINT DEFAULT 0, + UseCatalog TINYINT DEFAULT 1, + AcceptAnyVolume TINYINT DEFAULT 0, + VolRetention BIGINT UNSIGNED DEFAULT 0, + VolUseDuration BIGINT UNSIGNED DEFAULT 0, + MaxVolJobs INTEGER UNSIGNED DEFAULT 0, + MaxVolFiles INTEGER UNSIGNED DEFAULT 0, + MaxVolBytes BIGINT UNSIGNED DEFAULT 0, + AutoPrune TINYINT DEFAULT 0, + Recycle TINYINT DEFAULT 0, + PoolType VARCHAR(20) NOT NULL, + LabelFormat VARCHAR(128) NOT NULL, + Enabled TINYINT DEFAULT 1, + ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + UNIQUE (Name), + PRIMARY KEY (PoolId) + ); + +INSERT INTO Pool ( + PoolId, + Name, + NumVols, + MaxVols, + UseOnce, + UseCatalog, + AcceptAnyVolume, + VolRetention, + VolUseDuration, + MaxVolJobs, + MaxVolFiles, + MaxVolBytes, + AutoPrune, + Recycle, + PoolType, + LabelFormat, Enabled, ScratchPoolId, RecyclePoolId) + SELECT * FROM Pool_backup; + +DROP TABLE Pool_backup; + + DROP TABLE BaseFiles; CREATE TABLE BaseFiles ( diff --git a/bacula/src/stored/bacula-sd.conf.in b/bacula/src/stored/bacula-sd.conf.in index 3d6b277fce..3afd8ce65a 100644 --- a/bacula/src/stored/bacula-sd.conf.in +++ b/bacula/src/stored/bacula-sd.conf.in @@ -49,6 +49,7 @@ Device { # AutomaticMount = yes; # when device opened, read it # AlwaysOpen = yes; # RemovableMedia = yes; +# RandomAccess = no; #} # @@ -62,6 +63,7 @@ Device { # AutomaticMount = yes; # when device opened, read it # AlwaysOpen = Yes; # RemovableMedia = yes; +# RandomAccess = no; #} # diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 1983252465..d0d406c7a2 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -720,7 +720,8 @@ static int create_media_record(B_DB *db, MEDIA_DBR *mr, VOLUME_LABEL *vl) struct date_time dt; struct tm tm; - bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); + /* We mark Vols as Archive to keep them from being re-written */ + bstrncpy(mr->VolStatus, "Archive", sizeof(mr->VolStatus)); mr->VolRetention = 365 * 3600 * 24; /* 1 year */ if (vl->VerNum >= 11) { mr->FirstWritten = btime_to_utime(vl->write_btime); -- 2.39.5