2Do

How do I repair a corrupt database?

2Do uses the industry standard, SQLite embedded database to store your data. SQLite is lightweight, fast and can perform automatic recovery of failed or incomplete transactions under normal circumstances. In the rare event of a power-failure, sudden reboot or some other hardware related failure whilst in the middle of performing background sync, there is a slim chance of the database becoming corrupt, such that automatic recovery is no longer possible. This is more likely to occur on a Desktop / Laptop rather than an iPhone / Tablet. For phones and tablets, the easiest method of recovery, provided you have synced your data to the cloud, is to Reset your database from Settings > Advanced and setup sync to recover directly from the cloud.


Signs of a corrupt database are usually: search not working, sync not working or tasks not saving / deleting properly. Recovering from database failure is straightforward, albeit a manual process. The following instructions will help you self-diagnose a corrupt database and help you recover and repair your valued data. It should be noted here that 2Do creates automatic backups on a timely fashion (accessible from inside Preferences > Backups) for safe-keeping, however the following steps are there to help in case there isn’t a more recent backup to recover from.

  1. Spotlight for Terminal.app and launch it on your Mac
  2. Navigate to the db storage location by entering: cd ~/Library/Group\ Containers/EKT6323JY3.com.guidedways/
  3. Enter the following command and hit return: sqlite3 2do.db

The prompt should now display sqlite> to indicate you’re in the SQLite shell. To verify that you’re truly suffering from database corruption, enter the following command into the shell:

sqlite> PRAGMA integrity_check;

If the response is anything other than ok, the database is integrity checks have failed and needs to be repaired.

We need to now dump the data into an external file and re-create the database manually. Simply enter the following commands into the SQLite shell:

  1. sqlite> .mode insert
  2. sqlite> .output dump_all.sql
  3. sqlite> .dump
  4. sqlite> .exit

Now that we have the dump, let’s import it. You should now be out of the SQLite shell and back to the Terminal prompt. Execute the following statements:

  1. mv 2do.db 2do.orig.db
  2. sqlite3 2do.db < dump_all.sql
  3. sqlite3 2do.db

The first line above will move the original database out of the way. The second line will create a new one in place, using the dump we just exported. The last line should take us back into the SQLite shell in order to check if everything’s okay. Run the integrity check one more time and we should see OK as the response this time:

sqlite3> PRAGMA integrity_check;
ok

That’s it, you’re done repairing the database. Re-launch 2Do to get back to getting things done.
Attached Files
There are no attachments for this article.
Related Articles
Will 2Do ever show iCal events and tasks together in the same list?
Viewed 33,048.00 times since Tue, Jun 9, 2015
Will you develop 2Do for Windows?
Viewed 83,541.00 times since Sat, Dec 29, 2012
My data is only partially syncing
Viewed 9,874.00 times since Thu, Jun 11, 2015
I want a refund for my iOS / Mac app
Viewed 15,131.00 times since Wed, Jan 2, 2013
Do you support Student Discounts?
Viewed 17,283.00 times since Thu, Jul 23, 2015