None
SQ
Repairing database on the fly for millions of users
['Ashish Bhatia']
ashishb.net
Now, to prevent these users from losing messages, the messages were backed up to the user’s SD card. Java 1 2 3 4 5 6 7 8 9 // Dump database into SQL commands using SQLite shell // Remove the first 'BEGIN TRANSACTION' and the last 'END TRANSACTION' // Setup an empty database with all the tables and correct constraints // Start SQLite shell in `.bail off` mode // Restore the SQL commands from step 2 into the database using SQLite shell if (failedToRestore) { setupEmptyDatabase(); startSqliteShellAndRecover(); } Without revealing the precise number, I can say that the results were pretty good, most users lost only a few messages during this recovery process, and almost the full database was recovered for most of the users.