无法从SharePoint导出Web

时间:2016-03-11 18:19:04

标签: powershell sharepoint sharepoint-2010

我正在尝试通过powershell从根网站集导出SharePoint 2010中的网站,并且每个Export-SPWeb命令都会失败并显示此消息。

Export-SPWeb : String or binary data would be truncated.
The statement has been terminated.

对于我测试的任何网站集中的任何网站都会发生这种情况,而不仅仅是网络应用程序根目录。

根据我的理解,这是一个错误,表明网址长度超过260个字符。但是,即使站点中没有文件,也会发生这种情况。如果相关,则地址的FQDN为28个字符。

这是我尝试的一个实际示例(当然使用不同的主机名)。

> new-spweb http://sharepoint.example.com/a

Url
---
http://sharepoint.example.com/a

> export-spweb http://sharepoint.example.com/a -path "a.cmp"
Export-SPWeb : String or binary data would be truncated.
The statement has been terminated.
At line:1 char:13
+ export-spweb <<<<  http://sharepoint.example.com/a -path "a.cmp"
    + CategoryInfo          : InvalidData: (Microsoft.Share...CmdletExportWeb:SPCmdletExportWeb) [Export-SPWeb], SqlException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb

是否有人知道会发生这种情况的原因,以及可能如何修复它,因为错误消息似乎不正确?

1 个答案:

答案 0 :(得分:0)

在我们的案例中解决这个问题的方法似乎是将网站集备份和恢复到新创建的网站集。在我们的目标中,我们使用Export-SPWeb将大型网站集拆分为多个网站集,然后将Import-SPWeb拆分为新家。

实际上,这是我们所做的,如果它能帮助其他人解决同样的神秘问题。

首先确保主网站集备份的新网址不会超过260个字符的限制。如果它们超过260个字符,您仍然可以执行Backup-SPSite,但无法使用Restore-SPSite进行恢复。

example found on Microsoft forums进行了一些小修改。新网站集将在sites/NewSC

declare @oldSiteCollection nvarchar(20) = N'sites/old'
declare @newSiteCollection nvarchar(20) = N'sites/NewSC'

SELECT
   concat([DirName], N'/', [LeafName]) AS [FullRelativePath],
   len(concat(@newSiteCollection, [DirName], N'/', [LeafName])) - len(@oldSiteCollection) AS [Length]
FROM 
   [dbo].[AllDocs]
where
    [DirName] not like 'sites/%'
    and len(concat(@newSiteCollection, [DirName], N'/', [LeafName])) - len(@oldSiteCollection) > 260
ORDER BY 
   [FullRelativePath] desc

此查询将在以下命令成功之前提供要处理的事项列表。您希望在备份/恢复之前不从查询返回任何结果。

接下来是主网站集上的Backup-SPSite

Backup-SPSite http://sharepoint.example.com/sites/old -Path e:\old.bak

之后Restore-SPSite到新位置

Restore-SPSite http://sharepoint.example.com/sites/NewSC -Path e:\old.bak

在完成整个操作之后,Export-SPWeb按预期工作。

如果我不得不猜测为什么会出现此问题,可能是因为自SharePoint 2003以来我们一直在使用相同的内容数据库。从2003年到2007年升级到2010年可能会对这些数据造成影响。 / p>

考虑到这一点,将Move-SPSite用于新的内容数据库也无法解决此问题。经过数周的各种尝试后,唯一可行的是上述方法。