praeclarum / sqlite-net

Simple, powerful, cross-platform SQLite client and ORM for .NET
MIT License
4.07k stars 1.42k forks source link

syncing the files and metadata to skydrive #113

Open Xyroid opened 12 years ago

Xyroid commented 12 years ago

Hi, I am developing a note taking app. User will write note and he can set some metadata like location, note date time, etc. I am using SQLite for metadata and note will be RTF file. Now I want to have skydrive sync for that app. So user can access/backup/restore notes and its metadata from any Windows 8 device. I can upload and download files easily, but what approach should I use to sync the SQLite database ? Please guide me with some sample code.

mattleibow commented 12 years ago

maybe this can help a bit: http://www.sqlite.org/backup.html

On Tue, Oct 2, 2012 at 9:40 AM, Xyroid notifications@github.com wrote:

Hi, I am developing a note taking app. User will write note and he can set some metadata like location, note date time, etc. I am using SQLite for metadata and note will be RTF file. Now I want to have skydrive sync for that app. So user can access/backup/restore notes and its metadata from any Windows 8 device. I can upload and download files easily, but what approach should I use to sync the SQLite database ? Please guide me with some sample code.

— Reply to this email directly or view it on GitHubhttps://github.com/praeclarum/sqlite-net/issues/113.

Emasoft commented 12 years ago

Interesting, but what is the equivalent c# syntax to do such incremental online backup of the DB using SQlite.NET? I'm also trying to find a way to backup my iPhone app DB to iCloud incrementally (writing to iCloud only the differences).

CreepyGnome commented 11 years ago

That link states all your options, the first of which mean the easiest, which is just coping the database.

From the top of the page from the link provided above:

  1. Establish a shared lock on the database file using the SQLite API (i.e. the shell tool).
  2. Copy the database file using an external tool (for example the unix 'cp' utility or the DOS 'copy' command).
  3. Relinquish the shared lock on the database file obtained in step 1.

This is how I back it up, just make sure you don't have any open connections to the database and then copy it to wherever you want. You can google quickly how to copy files in C# and in MonoTouch as they are basically the same for this functionality.

SQLite is a single portable file, which is why its very popular.