Skip to main content
Newcomer
February 26, 2024
Solved

Scheduling an extract of metadata

  • February 26, 2024
  • 8 replies
  • 32 views

I'm being asked to schedule an extract of the OneStream metadata.  I'm under the impression that this cannot be done using the Task Scheduler since an extract of metadata is not an option in Data Management.  Is this an accurate statement?  If this can be schedule, how so?

Thanks!

Best answer by KayneSchwarz

Extender: Automate Application Metadata Backup

This is an example Extender rule that extracts all application metadata to a zip file, for the current application.
The file is created in the application Data Management Export folder, in the File Share directory

 

'Prepare the Stage Data Extract File path
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)

'Folder path to save export
Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, _
True, configSettings.FileShareRootFolder, si.AppToken.AppName) & _
"\" & DateTime.UtcNow.ToString("yyyyMMdd") & "\MetadataExtracts"

'Check if folder path for export exists
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
end if

Dim filePath As String = folderPath & "\" & si.AppToken.AppName & ".zip"

'Check if file already exists. If so then delete exsiting copy
If File.Exists(filePath) Then
File.Delete(filePath)
end if

'Set the extract options
Dim xmlOptions As New XmlExtractOptions
xmlOptions.ExtractAllItems = True

'Execute the Metadata Extract
Using dbConnFW As DBConnInfo = BRAPi.Database.CreateFrameworkDbConnInfo(si)
Using dbConnApp As DBConnInfo = BRAPi.Database.CreateApplicationDbConnInfo(si)

Dim zipBytes As Byte() = ApplicationZipFileHelper.Extract( _
dbConnFW, dbConnApp, Nothing, xmlOptions)

'Push the resulting content to a new zip file we create
Using FS As New FileStream(filePath, FileMode.Append, FileAccess.Write)

'Create a binary writer, and write all bytes to the FileStream at once
Using BW As New BinaryWriter(FS)
BW.Write(zipBytes)
End Using
End Using
End Using
End Using

 

8 replies

Expert
February 27, 2024

You can create a Business Rule to extract the metadata and then schedule that through Task Scheduler.

See here for more info:

https://community.onestreamsoftware.com/t5/Accepted-Code-Samples/Extender-Automate-Application-Metadata-Backup/ta-p/6914

 

Newcomer
February 27, 2024

I've built this rule successfully.  When I extract this file to my computer, how do I open the zip file?  When I open it I get the following.  I need the xml file of all the dimensions.  Thanks for the feedback!

ChrisFeller_0-1709047913269.png

 

Expert
February 27, 2024

You have selected to download the file in OneStream format (the down arrow). Double click should open the file in your zip application. Or you can download the file as a zip by clicking on the last icon on the toolbar (piece of paper with a down arrow).

MarcusH_0-1709050803873.png

 

 

KayneSchwarz
Community Admin
Community Admin
July 28, 2026

Extender: Automate Application Metadata Backup

This is an example Extender rule that extracts all application metadata to a zip file, for the current application.
The file is created in the application Data Management Export folder, in the File Share directory

 

'Prepare the Stage Data Extract File path
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)

'Folder path to save export
Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, _
True, configSettings.FileShareRootFolder, si.AppToken.AppName) & _
"\" & DateTime.UtcNow.ToString("yyyyMMdd") & "\MetadataExtracts"

'Check if folder path for export exists
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
end if

Dim filePath As String = folderPath & "\" & si.AppToken.AppName & ".zip"

'Check if file already exists. If so then delete exsiting copy
If File.Exists(filePath) Then
File.Delete(filePath)
end if

'Set the extract options
Dim xmlOptions As New XmlExtractOptions
xmlOptions.ExtractAllItems = True

'Execute the Metadata Extract
Using dbConnFW As DBConnInfo = BRAPi.Database.CreateFrameworkDbConnInfo(si)
Using dbConnApp As DBConnInfo = BRAPi.Database.CreateApplicationDbConnInfo(si)

Dim zipBytes As Byte() = ApplicationZipFileHelper.Extract( _
dbConnFW, dbConnApp, Nothing, xmlOptions)

'Push the resulting content to a new zip file we create
Using FS As New FileStream(filePath, FileMode.Append, FileAccess.Write)

'Create a binary writer, and write all bytes to the FileStream at once
Using BW As New BinaryWriter(FS)
BW.Write(zipBytes)
End Using
End Using
End Using
End Using