none
SQL Compact - Backup and Restore RRS feed

  • Question

  • Hey all,

    I am working on backing up and restoring a SQL Compact database that is involved in synchronization.  Since SQL Compact is file based, the backup and restore is nothing more than a file copy.  The question is how to get the sync framework straightened out.

    For example, let's say I have a client (SQL CE) and a server (SQL Azure) setup.  I make a backup at the client of the SQL CE database.  I then continue to update the client and sync with SQL Azure.  If I then restore the client database, the changes made on the client and synced with Azure do not come back down to the client.  In other words the two databases are then out of sync.

    The SqlSyncStoreRestore class only seems to work on SQL connections and not SQL CE connections -- so what do I need to do in order to get the client to refresh?

    Friday, October 28, 2011 1:13 AM

Answers

  • try using GenerateSnapshot to create your backup SDF instead of simply copying the SDF.

    • Marked as answer by Brian_I Sunday, October 30, 2011 9:17 PM
    Friday, October 28, 2011 12:45 PM
    Moderator

All replies

  • try using GenerateSnapshot to create your backup SDF instead of simply copying the SDF.

    • Marked as answer by Brian_I Sunday, October 30, 2011 9:17 PM
    Friday, October 28, 2011 12:45 PM
    Moderator
  • Fantastic. 

    I have two scenarios on the client

    1.  Restore backup (on client) and receive up to date info from the server

    2.  Restore backup (on client), reject all changes from the server and set the server to be identical to the restored backup

    The generatesnapshot suggestion takes care of the first scenario.  How about the second?

    Friday, October 28, 2011 5:27 PM
  • no easy approach for #2.

    you can do dummy updates on the client restored backup and force client to win if there's a conflict which would have the same effect as creating a new server db, provisioning and synching with the client restored SDF (the latter will be faster). but then you cant do the latter as well if you have other clients synching with the server db, so the former option will be better albeit expensive due to conflicts that may fire and need to be resolved.

    Sunday, October 30, 2011 12:56 PM
    Moderator
  • I had pretty much come to the same conclusion that it wasn't going to be easy.  I went ahead and came up with a way to do it, but it wasn't pretty.  Thanks for responding - at least I didn't miss something obvious.
    Sunday, October 30, 2011 9:17 PM