Replies: 1 comment 27 replies
-
Hi @karolgt1, DMS SnapshotsDMS can use "snapshots" to allow clients to bootstrap their sync with a lot of data coming from the server. You can read more about this feature here: https://dotmimsync.readthedocs.io/Snapshot.html Sql Server to Sql Server : Using a backupIf clients and server are both Sql Server, you can use backups, but it's not included "out of the box" in DMS. In your case, as there is no row marked as tracked in the server database, as well as in the client database, DMS "thinks" it's a first synchronization. First of all, if you are making a copy of the server database restored to the client, you need to be sure no rows will be added or removed to the server, before the client has restored the backup and synchronization has been initialized. So, if you want to use this kind of "technic" to start a new sync mechanism, based on a server backup, restored on a client, you can do it that way:
Here is a piece of code, that you can use as exploration: setup = new SyncSetup("ProductCategory");
var localOrchestrator = new LocalOrchestrator(clientProvider);
var remoteOrchestrator = new RemoteOrchestrator(serverProvider);
// 1) Make a backup of the server database
// ....
//
// 2) Provision server database
var serverScope = await remoteOrchestrator.ProvisionAsync(setup);
// 3) Get the timestamp to use on the client
var serverTimeStamp = await remoteOrchestrator.GetLocalTimestampAsync();
// Once you have done the first step (1), you need to make Provision (2) and get timestamp (3)
// really quickly to be SURE you don't have any new / modified or deleted rows in the server
// database that are not in the backup and not tracked.
// Once (2) and (3) are done, you are safe and you have all the time for next steps...
// 4) Restore backup on client
// ...
//
// 5) Provision client
await localOrchestrator.ProvisionAsync(serverScope);
// 6) Get the local timestamp
var clientTimestamp = await localOrchestrator.GetLocalTimestampAsync();
// 7) Get scopeinfoclient
// ScopeInfoClient table contains all information fro the "next" sync to do (timestamp, parameters and so on ...)
var scopeInfoClient = await localOrchestrator.GetScopeInfoClientAsync();
// As we have some existing lines, we say it's not a new sync
scopeInfoClient.IsNewScope = false;
// Affecting the correct timestamp, the local one and the server one
scopeInfoClient.LastServerSyncTimestamp = serverTimeStamp;
scopeInfoClient.LastSyncTimestamp = clientTimestamp;
await localOrchestrator.SaveScopeInfoClientAsync(scopeInfoClient);
// We're done
// We can sync safely now
var agent = new SyncAgent(clientProvider, serverProvider, options);
var r = await agent.SynchronizeAsync(setup);
Console.Write(r.ToString()); Let me know if it's what you are looking for |
Beta Was this translation helpful? Give feedback.
-
Hi, i have client db (on different server than server db) which was created by copying mdf file. When i'm calling GetEstimatedChangesCountAsync it shows number of changes (in server db) equal to the number of all rows from all tables taking part in sync process. From Ms SQL SMS both dbs looks the same. Due to big amount of data i want to avoid long time copying of data which is not needed. Maybe should i copy the data in some other way?
Beta Was this translation helpful? Give feedback.
All reactions