Back Up of SSRS Reports using RS Utility

Back Up of SSRS Reports using RS Utility

In this article, I will show you how to take Back Up of SSRS Report using RS Utility.

Before starting this, go through below link which can help you to understand what is RS Utility?

http://msdn.microsoft.com/en-us/library/ms162839.aspx 

Now to Take back up of SSRS Report using RS Utility, we are going to create 2 files which are as below :

  • BackupReports.rss (.rss stands for Reporting Services Script File)
  • BackupReports.bat

1. First of all Create BackupReports directory in your D drive.

2. Now open Notepad and copy-paste following Code:

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+"\"+ItemPath

If(Not System.IO.Directory.Exists(BackupFolderNew )) Then
    System.IO.Directory.CreateDirectory(BackupFolderNew)
End If

rdlReport.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

3. Now save the above file into D:\BackupReports directory with name BackupReports.rss. 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.

4. Now again open Notepad and copy-paste following code.

set ItemPath=/StartSSRS

set ReportServerURL=http://localhost/Reportserver

set BackupFolder=D:\BackupReports

rs -i "D:\BackupReports\BackupReports.rss" -s %ReportServerURL% -v ItemPath="%ItemPath%" -v BackupFolder="%BackupFolder%"

5. Now save the file into D:\BackupReports directory with name BackupReports.bat. 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. BackupFolder is the location where backup of report is stored.

6. Now double click on BackupReports.bat file and you will see result looks like following screenshot.

6-Back Up of SSRS Reports using RS Utility

7. Now Open BackupFolder location. There 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.

7-Back Up of SSRS Reports using RS Utility

8. 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.

Congratulations! We successfully taken Back Up of SSRS Reports using RS Utility.

If any query than let me know.

For contact information, go to following link :

http://bhushan.extreme-advice.com/about-bhushan-shah/

8 thoughts on “Back Up of SSRS Reports using RS Utility

  1. Hi sunil,

    You are getting an error because ReportService2005.asmx doesn’t exist.

    To check whether it exists or not, go to following path.

    C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER2008\Reporting Services\ReportServer

  2. Hi Bhushan,
    Thanks a lot for writing this great article. It worked like a charm and helpful indeed. I need some help from you on this. It works fine when we have only reports under one folder but its failing if –
    1. There any other type of file under same folder like jpg, doc etc. This script backup the reports in alphabetic order. If any other format file fall in between, it stopped and skips other reports as well.
    2. If we have any folder under the mail project folder (/Main/abc) it stops immediately and not backup even a single report, as folders falls first than the report files.
    So, can you please help me if we can tweak this script to exclude other format files and also traverse sub folders and backup report files from there too?

    Thanks in advance !

  3. good script but one issue is this script fail in case we keep data source need little modification to read only rdl file names

Leave a Reply to Akhilesh sahu Cancel reply

Your email address will not be published. Required fields are marked *