RS Utility:
The RS.exe utility processes script that you provide in an input file. Use this utility to automate report server deployment and administration tasks.
Developers and report server administrators can perform operations on a report server through the use of the rs utility (RS.exe).
Reporting Services scripts can be used to run any of the Report Server Web service operations. Scripting can be used to copy security to multiple reports on a server, to add and delete items, to copy report server items from one server to another and more.
Syntax:
rs {-?} {-i input_file=} {-s serverURL} {-u username} {-p password} {-e endpoint} {-l time_out} {-b batchmode} {-v globalvars=} {-t trace}
Example:
rs –i c:\BackupReports\BackupReports.rss -s http://localhost/reportserver
Backup SSRS Reports from Deployed Servers To Local Hard Drives
To take backup using RS utility we have to create two files:
- BackupSSRS.rss(.rss Report server scripting file)
- BackupSSRS.bat
Let’s start step by step:
Step1: Create a new directory in C: drive with name “BackupReports”.
Step2: Copy and paste below lines of code in notepad and save the file as “BackupSSRS.rss” into new created folder defined in step 1.This script will take each reports under the path we provide, iterate through all the reports , gets report definitions from the server we provide, and save it into .rdl file under the location we gave through command line
Public Sub Main()
Try
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim Items as CatalogItem()
Dim Item as CatalogItem
Dim ReportName As String
Items = rs.ListChildren(ItemPath, false)
Console.Writeline()
Console.Writeline(“Reports Back Up Started.”)
For Each Item in Items
ReportName = ItemPath + “/” + Item.Name
Dim reportDefinition As Byte() = Nothing
Dim rdlReport As New System.Xml.XmlDocument
reportDefinition = rs.GetReportDefinition(ReportName)
Dim Stream As New MemoryStream(reportDefinition)
Dim curDate as Date = Date.Now()
Dim strDate as String = curDate.ToString(“dd-MM-yyyy”)
Dim BackupFolderNew as String = BackupFolder+”\”+strDate+”\”+ItemPathIf(Not System.IO.Directory.Exists(BackupFolderNew )) Then
System.IO.Directory.CreateDirectory(BackupFolderNew)
End IfrdlReport.Load(Stream)
rdlReport.Save(BackupFolderNew + “\” + Item.Name +”.rdl”)Console.Writeline(“Report ” + Item.Name +”.rdl Backed up Successfully”)
Next
Console.Writeline(“Reports Back Up Completed.”)
Console.Writeline()
catch e As Exception
Console.Writeline(e.Message)
End Try
End Sub
Step3: Copy and paste below script in new notepad file and save file as “backupSSRS.bat” into new created folder defined in step 1.
In this script, ItemPath is the location where reports are stored in the report server. ReportServerURL is the URL of ReportServer where reports are deployed. BackupReports is the location where backup of report is stored.
set ItemPath=/Report Project2
set ReportServerURL=http://localhost/Reportserver
set BackupFolder=C:\BackupReports
rs -i “C:\BackupReports\BackupSSRS.rss” -s %ReportServerURL% -v ItemPath=”%ItemPath%” -v BackupFolder=”%BackupFolder%”
pause
Be ensure now you have 2 files in “c:\BackupReports” with .rss and .bat extension.
Step 4: Now go to new created folder “C:\BackupReports” and right click on batch file (.bat extension) and run as an administrator and you will see result looks like following screenshot.
Step 5: after executing the batch file as mentioned in step 4, you can find the folder with the name of current date in dd-mm-yyyy format which contains back up of all the reports. Please check below screen shot..
We successfully taken Back Up of SSRS Reports using RS Utility.You can also execute batch file from windows task scheduler. So you can create one schedule which execute daily on particular time. This schedule will generate day-to-day folder with backup of reports into your BackupFolder.
Download Files: .Rss and .bat files