In all cases, do not forget to perform backups of your SQlite3 database as often as possible (at least several times a day)!

Adding a backup feature on the server side is as simple as running:


The above line will perform a background live backup of the main SQLite3 database, by steps of 1024 pages (i.e. it would process 1 MB per step, since default page size is 1024 bytes), performing a little sleep of 10 milliseconds between each 1 MB copy step, allowing main CRUD / ORM operations to continue uninterrupted during the backup.
You can even specify an OnProgress: TSQLDatabaseBackupEvent callback event, to monitor the backup process.

Note that TSQLRestServerDB.Backup or TSQLRestServerDB.BackupGZ methods are not recommended any more on a running mORMot database, due to some potential issues with virtual tables, especially on the Win64 platform. You should definitively use TSQLDatabase.BackupBackground() instead.

The same backup process can be used e.g. to save an in-memory SQLite3 database into a SQLite3 file, as such:

 if aInMemoryDB.BackupBackground('backup.db3',-1,0,nil) then

Above code will save the aInMemoryDB database into the 'backup.db3' file.

We wish you a safe and happy backup of your precious objects!