On 25 Jul 2018, at 10:56pm, Rune Torgersen <ru...@innovsys.com> wrote:
> Management wants to know if we're doing it correctly, or if there are > faster/easier ways to do backup (and check). Please excuse me mentioning things I'm sure you are already doing correctly. Your question is useful to many users and this response will be read by users of all levels of experience. The following answers depend on your code noting the result code returned by each call to the API and checking that it is SQLITE_OK or SQLITE_DONE as appropriate. So use an ASSERT, or write your own code to make this check and write a log entry or terminate with an error message if it gets an unexpected result. If you are not doing this, fix that as a high priority. The things you describe as doing now will work correctly if the backup API is allowed to do its job. The backup API has to restart each time a change is made to the database. If your logs show that the backup API terminates correctly for each of your files it seems that in your case there is enough time between changes to allow this to happen, perhaps not at the first backup attempt, but soon enough. Is it possible to suspend execution (and close all connections) while the databases are being backed up ? If so, it may be faster to close all connections to a database, then use an OS call to duplicate it, then start things going again. Restarting the server may also work around resource leaks and other programming errors. But your setup may rely on 24/7 availability making this impossible, or it might be programmatically difficult to get into the guts of your program and tell it to detach and suspend execution. Once your backups are taken you can run integrity checks on the /backup/ copies of the files, allowing the main program to proceed without interruption. This assumes you are maintaining at least two generations of backup. > Also wants to know if a backup done using the live backup API gives us an > exact copy (with any possible corruption) or if the backup is regenerated. The backup API copies each page of the source database to the destination database, from end to end. It copies even pages marked as not in use (e.g. deleted rows). It has no understanding of the structure of the database file and, if I understand the documentation correctly, would copy corrupt sequences without noticing them. Since you are asking questions about backup, it's worth mentioning that backup copies should be in different storage to the databases, preferably to a server or external drive. You're probably doing this already, but I have seen a disturbing number of cases where a drive failure lost both database and backup because there was no budget for an external drive, or a manager wanted all desks to have the same hardware. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users