Home > database >  Sqlite online backup API produced journal file, database file to open again, found empty
Sqlite online backup API produced journal file, database file to open again, found empty

Time:10-04

 
Rc=sqlite3_open (dbfile, & amp; PFile);
If (rc==SQLITE_OK)
{
PBackup=sqlite3_backup_init (pFile, "main", db, "main");
If (pBackup)
{
Do {
Rc=sqlite3_backup_step (pBakcup, 1);
} while (rc==SQLITE_OK | | rc==SQLITE_BUSY | | SQLITE_LOCKED);
Sqlite3_backup_finish (pBakcup);
}
Rc=sqlite3_errcode (pFile);
}
Sqlite3_close (pFile);


I use a serial mode, the code memory database db backup to a file database dbfile, once every 5 seconds call, no other database operations, I found that in the process will produce journal file, manually kill the process, sometimes have a journal on the disk, and then use sqlite3 database command to open the file, found that the database is empty, if the program crashes, restart data lost, not how to solve this problem?

CodePudding user response:

Was the backup collapse, there is no end of backup, would, of course, a problem
You should change the last backup a bak first name, and then start backup
One thousand backup fails, can use bak to recover back to last time

CodePudding user response:

reference 1/f, CKC response:
was backup collapse, no end of backup, of course, cause problems
You should change the last backup a bak first name, and then start backup
One thousand failed to backup, restore the previous bak back to using


Well, I program is the backup, in-memory database & lt; -- -- -- -- -- & gt; Disk database & lt; -- -- -- -- -- -- -- & gt; Disk backup database, I don't quite understand after the creation of the journal file, and then open my disk database, disk is to empty the database directly, if memory database was released, unable to recover, so empty?
  • Related