#1 2013-07-26 14:17:41

Roberto Schneiders
Member
From: Santa Catarina, Brazil
Registered: 2012-09-19
Posts: 127
Website

Help with BackupGZ and SQLite External

I'm testing methods for backup a SQLite database. More precisely BackupGZ.

This is my code:

var
  Props:TSQLDBConnectionProperties;
begin
  Model := CreateBigSampleModel;
  Props := TSQLDBSQLite3ConnectionProperties.Create('Teste.db3' , '', '', '');
  VirtualTableExternalRegister(Model,TSQLBigSampleData,Props, 'SampleRecord');
  Database := TSQLRestClientDB.Create(Model,nil,'MainDb.db3',TSQLRestServerDB,false,'');
  TSQLRestClientDB(Database).Server.DB.Synchronous := smOff;
  TSQLRestClientDB(Database).Server.DB.LockingMode := lmExclusive;
  TSQLRestClientDB(Database).Server.CreateMissingTables(0);
  TSQLRestClientDB(Database).Server.BackupGZ('Backup.gz');
end;

Apparently he is backing up MainDB.Db3 and not the actual base Teste.db3.

If I use this:

  Database := TSQLRestClientDB.Create(Model,nil,':memory:',TSQLRestServerDB,false,'');

An error occurs when backing up.

What is the correct way to backup a External SQLite database?

Offline

#2 2013-07-26 16:15:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,622
Website

Re: Help with BackupGZ and SQLite External

Roberto Schneiders wrote:

Apparently he is backing up MainDB.Db3 and not the actual base Teste.db3.

Yes, this is by design, since you are working at the TSQLRestClientDB(Database).Server.DB level, i.e. for MainDB.db3.

For the external table, you can use the MainConnection.

Offline

#3 2013-07-26 16:46:32

Roberto Schneiders
Member
From: Santa Catarina, Brazil
Registered: 2012-09-19
Posts: 127
Website

Re: Help with BackupGZ and SQLite External

Thanks

Only found this option. Is that correct?

TSQLDBSQLite3Connection(Props.MainConnection).DB.Backup('teste.bkp');

Is there any way to restore this backup in the framework?

It has some class that provides a method similar to BackupGz with compression?

Last edited by Roberto Schneiders (2013-07-26 16:48:48)

Offline

#4 2013-07-30 11:17:47

Roberto Schneiders
Member
From: Santa Catarina, Brazil
Registered: 2012-09-19
Posts: 127
Website

Re: Help with BackupGZ and SQLite External

I started to have problems with this backup method. Are experiencing the same error reported in these other posts.
http://synopse.info/forum/viewtopic.php?id=881
http://synopse.info/forum/viewtopic.php?id=643
http://synopse.info/forum/viewtopic.php?id=662

"cannot VACUUM - SQL statements in progress"

We do not perform any SQL command before running the backup. Simply open the program and ran the backup.

What is the correct way to back up an external database?

Offline

#5 2013-07-30 11:46:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,622
Website

Re: Help with BackupGZ and SQLite External

Roberto Schneiders wrote:

What is the correct way to back up an external database?

Do not open the database and copy the file.
wink

Offline

Board footer

Powered by FluxBB