{"id":519,"date":"2012-03-29T16:17:38","date_gmt":"2012-03-29T15:17:38","guid":{"rendered":"http:\/\/blog.repsaj.nl\/?p=519"},"modified":"2012-03-29T16:17:38","modified_gmt":"2012-03-29T15:17:38","slug":"sp2010-exporting-site-subscriptions-in-multi-tenant-setup","status":"publish","type":"post","link":"http:\/\/blog.repsaj.nl\/index.php\/2012\/03\/sp2010-exporting-site-subscriptions-in-multi-tenant-setup\/","title":{"rendered":"SP2010: Exporting site subscriptions in multi tenant setup"},"content":{"rendered":"<p>I created this little script I wanted to share, which loops though a web application; finds all site subscriptions (for multitenancy) and exports both the sites in there and the settings of the subscription. You could use the result to import the sites again into a test environment (for instance).<\/p>\n<p><code><br \/>\n$url = \"http:\/\/contoso.com\"<br \/>\n$share = \"\\\\server\\backup\\\"<\/p>\n<p>$wa = Get-SPWebApplication $url<\/p>\n<p>foreach ($sub in $wa.SiteSubscriptions)<br \/>\n{<br \/>\n\tWrite-Host Exporting site subscription $sub.Id<\/p>\n<p>\t# create the folder (skipped when it exists<br \/>\n\t$folder = $share + $sub.Id<br \/>\n\tif(!(test-path $folder -pathtype container))<br \/>\n\t{<br \/>\n\t\tNew-Item -Path $folder -ItemType directory<br \/>\n\t}<\/p>\n<p>\t$exportPath = $folder + \"\\subscriptionsettings.bak\"<br \/>\n\tExport-SPSiteSubscriptionSettings $sub -Path $exportPath -Force<\/p>\n<p>\tforeach ($site in $sub.Sites)<br \/>\n\t{<br \/>\n\t\tWrite-Host Exporting site $site.Id<br \/>\n\t\t$backupPath = $folder + \"\\\" + $site.Id + \".bak\"<br \/>\n\t\tBackup-SPSite $site -Path $backupPath -Force<br \/>\n\t}<br \/>\n}<br \/>\n<\/code><\/p>\n<p>There are some other scripts out there which use Get-SPSiteSubscription -ReturnSites, but that parameter doesn&#8217;t exist in my environments. I think it might be a left over from the beta phase. Also that script you would have to use per subscription, the script above works per web application. And with one more foreach-loop, you could run it across all webapplications too. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I created this little script I wanted to share, which loops though a web application; finds all site subscriptions (for multitenancy) and exports both the sites in there and the settings of the subscription. You could use the result to import the sites again into a test environment (for instance). $url = &#8220;http:\/\/contoso.com&#8221; $share =<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[45,7,46],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3KFR1-8n","_links":{"self":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/519"}],"collection":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/comments?post=519"}],"version-history":[{"count":0,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/519\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/media?parent=519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/categories?post=519"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/tags?post=519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}