This article explains how to download the all RDL files from
ReportManager. We can download all the RDL files at a time using RS.exe
utility. RS.exe utility is a command line utility that can perform many
scripted operation related to SQL Server Reporting Services (SSRS).
Note: Rs.exe file path will change based on the SQL Server/SSRS version
EXE file is located any one of the below locations (Based on SQL Server/SSRS Version):
For 64 Bit: \Program Files\Microsoft SQL Server\100\Tools\Binn
For 64 Bit: \Program Files\Microsoft SQL Server\100\Tools\Binn
For 32 Bit: \Program Files (x86)\Microsoft SQL Server\100\Tools\Binn
OR
OR
For 64 Bit: \Program Files\Microsoft SQL Server\110\Tools\Binn
For 32 Bit: \Program Files (x86)\Microsoft SQL Server\110\Tools\Binn
OR
For 64 Bit: \Program Files\Microsoft SQL Server\120\Tools\Binn
For 32 Bit: \Program Files (x86)\Microsoft SQL Server\120\Tools\Binn
For this process we need to prepare two files
- Script File (For downloading all RDL Files)
- Batch file (To execute the RS.exe based on script present in the script file)
1. Script
to prepare ScriptFile (Copy
the below script and past it in text file and save with the name and extension
as “Download_all_RDL_files.rss”):
'Script Starting Point
'This script downloads the all RDL files from ReportServer
Sub Main()
Dim items As CatalogItem() = _
rs.ListChildren("/", true)
For Each item As CatalogItem in items
If item.Type = ItemTypeEnum.Folder Then
CreateDirectory(item.Path)
Else If item.Type = ItemTypeEnum.Report Then
SaveReport(item.Path)
End If
Next
End Sub
Sub CreateDirectory(path As String)
path = GetLocalPath(path)
System.IO.Directory.CreateDirectory(path)
End Sub
Sub SaveReport(reportName As String)
Dim reportDefinition As Byte()
Dim document As New System.Xml.XmlDocument()
reportDefinition = rs.GetReportDefinition(reportName)
Dim stream As New MemoryStream(reportDefinition)
document.Load(stream)
document.Save(GetLocalPath(reportName) + ".rdl")
End Sub
Function GetLocalPath(rsPath As String) As String
Return rootPath + rsPath.Replace("/", "\")
End Function
'End of the Script
'This script downloads the all RDL files from ReportServer
Sub Main()
Dim items As CatalogItem() = _
rs.ListChildren("/", true)
For Each item As CatalogItem in items
If item.Type = ItemTypeEnum.Folder Then
CreateDirectory(item.Path)
Else If item.Type = ItemTypeEnum.Report Then
SaveReport(item.Path)
End If
Next
End Sub
Sub CreateDirectory(path As String)
path = GetLocalPath(path)
System.IO.Directory.CreateDirectory(path)
End Sub
Sub SaveReport(reportName As String)
Dim reportDefinition As Byte()
Dim document As New System.Xml.XmlDocument()
reportDefinition = rs.GetReportDefinition(reportName)
Dim stream As New MemoryStream(reportDefinition)
document.Load(stream)
document.Save(GetLocalPath(reportName) + ".rdl")
End Sub
Function GetLocalPath(rsPath As String) As String
Return rootPath + rsPath.Replace("/", "\")
End Function
'End of the Script
2. Command to prepare BatchFile (Copy the below command and past it in text file and save with the name and extension as “DownloadRdlFiles.bat”):
Note: Verify the rs.exe file path in your Machine and Update the below path if the file is present in different location.
Note: Verify the rs.exe file path in your Machine and Update the below path if the file is present in different location.
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\rs.exe" -s "http://admin-pc:8080/ReportServer" -i C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Download_rdl_files\Download_all_RDL_files.rss -v rootPath="C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Download_rdl_files\RDL_files\\"
Pause
Pause
After preparing two files (Script File and Batch File), edit the batch file and update the "Rs.exe file path, ReportServer URL, .RSS script file path and RootPath (Local path, where we need to keep the RDL files)".
- Rs.exe file path: Update with the Rs.exe file path (file is located at \Program Files\Microsoft SQL Server\110\Tools\Binn)
- ReportServer URL: Update with the required ReportServer URL (From where we need to download RDL files)
- .RSS script file path: Update with the .rss script file path (where we placed the ScriptFile "Download_all_RDL_files.rss" file).
- RootPath: Update with the required path (where we need to place the downloaded RDL files)
Sample Folder Structure:
After Updating the Script and Batch files, double click on the batch file then execution will start.
Also:
Upload Multiple RDL Files from Local path to ReportServer (Using Rs.Exe Utility)
After Updating the Script and Batch files, double click on the batch file then execution will start.
Also:
Upload Multiple RDL Files from Local path to ReportServer (Using Rs.Exe Utility)
Excelent, this worked. I only has had to add Username and Passwort in the Connection to the Report Server.
ReplyDeleteGreat Work, thanks
thank you so much.
Deletewhere need to add user name & password
DeleteIn the Batch file we can add UserName and Password.
DeleteExample (Batch File Code):
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\rs.exe" -s "http://admin-pc:8080/ReportServer" -u "Username" -p "Password" -i C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Download_rdl_files\Download_all_RDL_files.rss -v rootPath="C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Download_rdl_files\RDL_files\\"
Pause
Great Job. Really good. we have multiple folders in reports server so that can it is possible that we can export the rdl of specific folder.
ReplyDeleteThanks. Yes we can export RDL files to specific folder, please find the below link.
Deletehttp://basic-ssrs.blogspot.in/2015/12/upload-multiple-rdl-files-from-local.html
Hey Kiran,
DeleteI am not getting how to use reference from the multiple reports upload link you gave above. Do we have to declare file_path and root_path differently for downloading any specific folder rdl's.
I have update the Upload RDL file post, please go throw and let me know if you need any clarification.
DeleteBrief description about uploading RDL Files:
We need to prepare three files.
• Script File: The script file picks the multiple RDL files from specific folder and uploads into target SSRS report server folder (source and target paths we need to update in the “Configuration File”)
• Configuration File: we need to update this file with source RDL file path and report server path
• Batch File: it invokes the RS.exe file based on the Script file.
Getting an error "Unrecognized argument files"
ReplyDeleteHi Brain,
DeletePlease verify the rs.exe file path in your machine (Based on SQL Server/SSRS version path will change). If the file is located in different location then update the same location.
If the rs.exe file is present in the same location, then verify the Script file and Batch file code.
Excellent tutorial to Download all RDL files. But I also want to download Data Sources(.rsds) from Report Manager. Can you please provide script for that?
ReplyDeleteThanks Vikas.
DeleteRight now I don’t have the script to download the RDS files. Will work on it and update you.
Excellent work! I am able to download all the folders from my dev server whereas I am not able to download all the folders except User Folders from prod. Also in prod environment, I do not see Microsoft SQL Server\110\Tools\Binn instead I have Microsoft SQL Server\100\Tools\Binn. Any help would be appreciated
ReplyDeleteThanks Subrahmanyam,
DeleteBased on SQL Server/SSRS Version, the rs.exe file path will change. I think your machine is having SQL Server 2008 version, due to that the file is present in different location
It works for me. Great Job
ReplyDeleteThank you so much - saved me so much time!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI had to change Lines 6, 8 & 23 for this codfe to work with ReportingService2010.dll.
ReplyDeleteLine 6 = If item.TypeName = "Folder" Then
Line 8 = Else If item.TypeName = "Report" Then
Line 23 = reportDefinition = rs.GetItemDefinition(reportName)
Good stuff
ReplyDeleteReally helpful - Thanks
Looks like you still might answer questions about this. I am getting an error from the VB compiler Name 'rootPath' is not declared. then it shows the last line in the rss file where rootPath is used. I am passing a fully qualified path from the bat file
ReplyDelete-v rootFile="E:\imta\setup\imtareports\download"
I'm at a loss