After some additional validation you can use the initialize from backup for a pull subscription. The issue above requires an additional parameter called publisher_db that needs to be included in the last 2 sql scripts. I did get this to work when it was all on one server however when I try it on 2 servers I received the same error message regarding the publication not existing:
I ran into an issue when setting this up on 2 servers - Here are the steps:
1. Set up distribution on subscriber server
2. Create a publication and set it to allow intialization from backup
3. Perform full backup
4. copy backup over to subscriber and restore
5. Run the following command on the publisher:
sp_addsubscription
@PUBLICATION='Test_Publication',
@SUBSCRIBER='XXXXXXSQL012',
@destination_db='Repl_Subscriber',
@SYNC_TYPE='initialize with backup',
@BACKUPDEVICETYPE='disk',
@subscription_type='pull',
@backupdevicename='\\XXXXXXSQL012\d$\Backup\Repl_Publisher4test.bak'
6. Run the following command on the subscriber:
sp_addpullsubscription
@PUBLISHER='XXXXXXSQL010',
@PUBLICATION='Test_Publication',
@subscription_type='pull',
@publisher_db='Repl_Publisher'
7. Run the following command on the subscriber:
sp_addpullsubscription_agent
@PUBLISHER='XXXXXXSQL010',
@PUBLICATION='Test_Publication',
@DISTRIBUTOR='XXXXXXSQL012',
@PUBLISHER_DB='Repl_Publisher',
@frequency_type=64
All of these commands run however when I look in replication monitor it shows the subscription as uninitialized and the distribution job shows failed - it starts up, connects to the subscriber, connects to the distributor and then gives an agent message code 20026. The publication 'Test_Publication' does not exist which is the same issue I had initially before the recommendation to add the publisher_db variable so I am not sure what the heck is missing here. Here is the details of the command in the distribution job:
-Publisher XXXXXXSQL010 -PublisherDB [Repl_Publisher] -Publication [Test_Publication] -Distributor [XXXXXXSQL012] -SubscriptionType 1 -Subscriber [XXXXXXSQL012] -SubscriberSecurityMode 1 -SubscriberDB [Repl_Subscriber] -Continuous
Also I noticed that 2 of the 3 sql jobs (snapshot and logreader) are created on the publisher whereas when you do this using the snapshot they are created on the subsciber. I am concerned with where the overhead would be placed so I am wondering if there is a way to have those created on the subscriber as well.
If I can get this to work I'll post the answer.