Sunday, October 11, 2015

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?
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:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 nameBackupReports.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.
?
1
2
3
4
5
6
7
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 nameBackupReports.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 :