Subject: Restore Folders in a mailfile from a Tape
I wrote some script (quick & dirty) that loops through all folders in the restored db. Then it loops through all the documents in the folder, gets the DocUniqueID an looks if he can find the same DocUniqueID in the active Mail-DB.If yes, he will put it in the same folder as in the restored db.
Data for server name and replica ID is taken from a small setup document. The script is in a button in the setup-doc.
Here is the code:
Sub Click(Source As Button)
'Basisdeklarationen
Dim uiws As New NotesUIWorkspace
'Objektdeklarationen
Dim sourcedb As NotesDatabase
Dim sourcedoc As NotesDocument
Dim sourceview As NotesView
Dim targetdb As NotesDatabase
Dim targetdoc As NotesDocument
Dim uidoc As NotesUIDocument
'Variablendeklarationen
Dim docunid As String
Dim foldername As String
Dim message As String
Dim sourcedbid As String
Dim sourcedbserver As String
Dim targetdbid As String
Dim targetdbserver As String
'Startwerte setzen
Set uidoc = uiws.CurrentDocument
'Verbindungsdaten auslesen
sourcedbserver = uidoc.FieldGetText("Ft_SourceDBServer")
sourcedbid = uidoc.FieldGetText("Ft_SourceDBID")
targetdbserver = uidoc.FieldGetText("Ft_TargetDBServer")
targetdbid = uidoc.FieldGetText("Ft_TargetDBID")
'Erstmal den Doppelpunkt aus den Replik-IDs filtern
sourcedbid = Left$(sourcedbid,8)+Right$(sourcedbid,8)
targetdbid = Left$(targetdbid,8)+Right$(targetdbid,8)
'Quell-DB öffnen
Set sourcedb = New NotesDatabase("","")
If Not sourcedb.OpenByReplicaID(sourcedbserver,sourcedbid) Then
message = "Quelldatenbank konnte nicht geöffnet werden"
Messagebox message,16,"Fehler"
Exit Sub
End If
'Ziel-DB öffnen
Set targetdb = New NotesDatabase("","")
If Not targetdb.OpenByReplicaID(targetdbserver,targetdbid) Then
message = "Zieldatenbank konnte nicht geöffnet werden"
Messagebox message,16,"Fehler"
Exit Sub
End If
'Loop durch alle Ansichten in der Quell-DB
Forall v In sourcedb.Views
If v.IsFolder Then
foldername = v.Name
Set sourcedoc = v.GetFirstDocument
'Loop durch alle Dokumente im Folder
Do While Not sourcedoc Is Nothing
docunid = sourcedoc.UniversalID 'DocUniqueID auslesen
Set targetdoc = targetdb.GetDocumentByUNID(docunid) 'Gegenstück in der Zieldatenbank finden
If Not targetdoc Is Nothing Then
Call targetdoc.PutInFolder(foldername)
End If
Set sourcedoc = v.GetNextDocument(sourcedoc)
Loop
End If
End Forall
End Sub