Transferring Snapshots

SQL Replication

Replication

Transferring Snapshots

Before a new Subscriber can receive incremental changes from a Publisher, it must contain tables with the same schema and data as the tables at the Publisher. After the snapshot is created at the Publisher and stored, you need to transfer the snapshot to the Subscriber, either using Microsoft® SQL Server™ 2000 replication agents or manually.

SQL Server Applies the Initial Snapshot

When SQL Server 2000 applies the snapshot to Subscribers, either the Distribution Agent (for snapshot replication and transactional replication) or the Merge Agent (for merge replication) applies the schema and data files to the subscription database on the Subscriber.

Unless you are using transactional replication with concurrent snapshot processing, share locks are held while the snapshot is generated so a full, logical, and consistent set of data is produced. This means that while the data can be queried, it cannot be updated during the time it takes to generate the snapshot. To minimize any inconvenience to your operations, always plan to generate a snapshot when updates are minimal. If you are using transactional replication, concurrent snapshot processing allows you to continue data modifications while the snapshot is generated. For more information, see Improving Performance While Generating and Applying Snapshots.

For merge replication, the process is similar to concurrent snapshot processing for transactional replication because locks are in place only for the duration of the copy of the merge contents table. The tables are not locked when the snapshot is being bulk copied and updates at the publication database are not prevented for the duration of the entire snapshot.

When snapshots are distributed and applied to Subscribers, only those Subscribers waiting for initial or new snapshots are affected. Other Subscribers to that publication (those that are already receiving inserts, updates, deletes, or other modifications to the published data) are unaffected.

You can specify that SQL Server 2000 should initialize the schema and data on the Initialize Subscription page in the Create Push Subscription or Create Pull Subscription Wizard.

When the first synchronization occurs (which you specify to occur immediately in the subscription wizards), the Distribution Agent or Merge Agent applies the initial snapshot and then proceeds to propagate updates and other data modifications.

Applying the Snapshot Manually

If the publication is large, it may be more efficient to load the snapshot from a compact disc, or other storage device.

For example, if you have a 20 GB database, it may be easier and faster to dump the database to removable media, express courier it to the Subscriber location, and reload the database instead of sending the file over a slow network. If you decide to load the snapshot this way, SQL Server 2000 will not synchronize the published articles with the destination tables.

For this example to work effectively in merge replication, you must have pre-created and populated the ROWGUIDCOL column or have already run the Snapshot Agent at the Publisher. Applying the snapshot is still required so that system tracking data and objects necessary for merge replication are at the Subscriber.

It is recommended that you use attachable subscription databases when you need to apply a large snapshot rather than using a combination of standard and dynamic snapshots and alternate snapshot locations with compression. For more information, see Attachable Subscription Databases.

With SQL Server 2000, you can store snapshots in a location other than or in addition to the default location, and you can browse snapshot folders, so it is easier to view, copy and move snapshot files.

To apply the snapshot manually, you can:

  • Save the snapshot files to removable media such as a compact disc, tape device, or removable disk and then send the media to the Subscriber location.

  • Base the initial snapshot off a database dump.

You can specify that the Subscriber already have the schema and data on the Initialize Subscription page in the Create Push Subscription or Create Pull Subscription Wizard.

The Distribution Agent or Merge Agent then assumes that the Publisher and Subscriber are already synchronized, and starts sending inserts, updates, deletes, or other modifications to the published data immediately.

If a current snapshot is not already waiting, SQL Server will wait until the next time the Snapshot Agent runs according to its schedule (by default, that is once a day at 1 A.M.) before applying the snapshot to the new Subscriber.

If you create a publication and enable it for anonymous subscriptions or if you specify that the snapshot should be retained in the snapshot location (both of these are options in the Create Publication Wizard), the snapshot will run at its scheduled time and it will be retained in the snapshot location. If you do not choose one of these options, the snapshot will not be retained, therefore, when a new Subscriber attempts to synchronize for the first time, it will have to wait until the next time a snapshot is generated to have the snapshot applied.