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 problemYou 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: