我有一个SSRS
报告数据备份,已在本地计算机上还原。
我使用了一个查询,该查询从目录表返回了RDL
原始XML
,但是我发现服务器有10多个报告,甚至我都无法在生产数据库中查看。
我的问题是,我在哪里找到RDL
文件,而Reporting Server显示72 RDL
,而报告数据库中的目录表仅显示10。
答案 0 :(得分:2)
您可以使用以下脚本运行所有已部署报告的备份。
%systemroot%/system32/mstsc.exe
parentFolder=""
作为零字符串运行它,以保存整个文件夹结构以及所有报告。 命令行:
rs -s http://localhost/reportserver -i D:\Scripts\Backup_Reports.rss -e Mgmt2010 -v backupFolder="D:\Scripts\BackupReports" -v parentFolder=""
报告备份过程:
Public Sub Main()
'--------------------------------------------------------------------------------------------------------------------
' Purpose: Script to backup reports from a folder on ReportServer
' Save file as .rss extension and run using rs.exe from command line.
' Reference: http://bhushan.extreme-advice.com/back-up-of-ssrs-reports-using-rs-utility/
' https://docs.microsoft.com/en-us/sql/reporting-services/tools/rs-exe-utility-ssrs?view=sql-server-2017
' Example: rs -s http://localhost/reportserver -i D:\Scripts\Backup_Reports.rss -e Mgmt2010 -v backupFolder="D:\Scripts\BackupReports" -v parentFolder="/IndividualReportFolderNameHere"
' rs -s http://localhost/reportserver -i D:\Scripts\Backup_Reports.rss -e Mgmt2010 -v backupFolder="D:\Scripts\BackupReports" -v parentFolder=""
'--------------------------------------------------------------------------------------------------------------------
Try
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim items As CatalogItem() = Nothing
If String.IsNullOrEmpty(parentFolder) Then
items = rs.ListChildren("/", True)
Else
items = rs.ListChildren(parentFolder, False)
End If
Console.WriteLine()
Console.WriteLine("...Backup Started...")
For Each item As CatalogItem In items
If item.TypeName = "Report" Then
Console.WriteLine(item.Path)
Dim reportPath As String = item.Path
parentFolder = Path.GetDirectoryName(item.Path) ' comment out this line to save the reports in one folder
Dim reportDefinition As Byte() = rs.GetItemDefinition(item.Path)
Dim rdlReport As New System.Xml.XmlDocument
Dim Stream As New MemoryStream(reportDefinition)
Dim backupPath As String = Path.Combine(backupFolder, Date.Now().ToString("yyyy.MM.dd") + "\" + parentFolder)
If (Not System.IO.Directory.Exists(backupPath)) Then
System.IO.Directory.CreateDirectory(backupPath)
End If
rdlReport.Load(Stream)
rdlReport.Save(Path.Combine(backupPath, item.Name + ".rdl"))
Console.WriteLine(item.Name + ".rdl")
End If
Next
Console.WriteLine("...Backup Completed...")
Console.WriteLine()
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub