def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN CmdLineId INTEGER") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN ServerSession TEXT") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN Full INTEGER DEFAULT 0") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN ClientVersion CHARACTER") conn.execute("ALTER TABLE Backups ADD COLUMN ServerVersion CHARACTER") conn.execute("ALTER TABLE Backups ADD COLUMN ClientIP CHARACTER") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN PurgeTime TEXT") conn.execute("ALTER TABLE Backups ADD COLUMN ClientEndTime TEXT") conn.execute("ALTER TABLE Backups ADD COLUMN Vacuumed INTEGER DEFAULT 0") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) ### # Do this all 'manually', because a SQL only version seems to throw SQLite3 into an infinite loop. # Would be much cleaner if UPDATE supported an AS keyword, like SELECT does. conn.execute("PRAGMA journal_mode=truncate") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) ### # Do this all 'manually', because a SQL only version seems to throw SQLite3 into an infinite loop. # Would be much cleaner if UPDATE supported an AS keyword, like SELECT does. conn.execute("ALTER TABLE Backups ADD COLUMN SchemaVersion INTEGER") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute( 'UPDATE Checksums SET Compressed = "zlib" WHERE Compressed IS 1') conn.execute( 'UPDATE Checksums SET Compressed = "none" WHERE Compressed IS 0') convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Files ADD COLUMN XattrId INTEGER") conn.execute("ALTER TABLE Files ADD COLUMN AclId INTEGER") conn.execute("ALTER TABLE CheckSums ADD COLUMN DiskSize INTEGER") conn.execute("ALTER TABLE CheckSums ADD COLUMN ChainLength INTEGER") conn.execute('INSERT OR REPLACE INTO Config (Key, Value) VALUES ("SchemaVersion", "3")') print "Setting chain lengths" conn.execute("UPDATE Checksums SET ChainLength = 0 WHERE Basis IS NULL") rnd = 0 while True: c = conn.execute("SELECT COUNT(*) FROM Checksums WHERE ChainLength IS NULL") r = c.fetchone() print "Round %d: Remaining empty chainlengths: %d" % (rnd, r[0]) rnd += 1 if r[0] == 0: break conn.execute("UPDATE Checksums " "SET ChainLength = 1 + (SELECT ChainLength FROM Checksums C WHERE C.Checksum == CheckSums.Basis) " "WHERE (Basis IS NOT NULL) AND (ChainLength IS NULL) AND " "Basis IN (SELECT Checksum FROM Checksums WHERE Chainlength IS NOT NULL)") print "Setting data sizes" cache = CacheDir.CacheDir(os.path.dirname(db)) c = conn.execute("SELECT COUNT(*) FROM Checksums WHERE DiskSize IS NULL") r = c.fetchone() numrows = r[0] print numrows # Get all non-sized files. Order by checksum so that we can get locality in the directories we read c = conn.execute("SELECT Checksum FROM Checksums WHERE DiskSize IS NULL ORDER BY Checksum") checksums = c.fetchall() # Build a progress bar, if we have that module. Just for grins. c2 = conn.cursor() x = 0 for i in checksums: checksum = i[0] size = os.path.getsize(cache.path(checksum)) #print "Setting size of %s to %d" % (checksum, size) c2.execute("UPDATE Checksums SET DiskSize = ? WHERE Checksum = ?", (size, checksum)) x += 1 convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Checksums ADD COLUMN Added INTEGER") conn.execute("ALTER TABLE Checksums ADD COLUMN IsFile INTEGER" ) # Old version only uses checksums for files. conn.execute("UPDATE Checksums SET IsFile = 1") # This can be really slow. Only enable it if you really want it. # conn.execute("UPDATE Checksums SET Added = (SELECT MIN(FirstSet) FROM Files WHERE Files.ChecksumID = Checksums.ChecksumID OR Files.XattrID = Checksums.ChecksumID OR Files.AclID = Checksums.ChecksumId)") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN ClientConfigId INTEGER") conn.execute( """ CREATE TABLE IF NOT EXISTS ClientConfig ( ClientConfigID INTEGER PRIMARY KEY AUTOINCREMENT, ClientConfig TEXT ) """ ) convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Backups ADD COLUMN FilesFull INTEGER") conn.execute("ALTER TABLE Backups ADD COLUMN FilesDelta INTEGER") conn.execute("ALTER TABLE Backups ADD COLUMN BytesReceived INTEGER") conn.execute("ALTER TABLE CheckSums ADD COLUMN Encrypted INTEGER") conn.execute( "UPDATE CheckSums SET Encrypted = 1 WHERE InitVector IS NOT NULL") conn.execute("UPDATE CheckSums SET Encrypted = 0 WHERE InitVector IS NULL") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("ALTER TABLE Config RENAME TO _Config_Orig") conn.execute(""" CREATE TABLE IF NOT EXISTS Config ( Key TEXT PRIMARY KEY, Value TEXT NOT NULL, Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP ); """) conn.execute("INSERT INTO Config (Key, Value, Timestamp) " + " SELECT Key, Value, NULL FROM _Config_Orig") conn.execute("DROP TABLE _Config_Orig") convertutils.updateVersion(conn, version, logger) conn.commit()
def upgrade(conn, logger): convertutils.checkVersion(conn, version, logger) conn.execute("CREATE INDEX IF NOT EXISTS InodeIndex ON Files(Inode ASC, Device ASC, Parent ASC, ParentDev ASC, FirstSet ASC, LastSet ASC)") convertutils.updateVersion(conn, version, logger) conn.commit()