Tip

How to automatically create a backup copy of your Domino Directory

This Lotus Notes agent will automatically create a backup copy of your Domino Directory. Now you'll never need to restore documents back to Domino Directory or check your old configurations.

VIEW MEMBER FEEDACK TO THIS TIP

 

 

This Lotus Notes agent works by creating a new copy of the Domino Directory under an archive directory. It can be scheduled to run monthly and can be easily modified to create a backup copy of any database from any Lotus Domino server.

 Sub Initialize Dim dbOrigin As NotesDatabase Dim dbArchive As NotesDatabase Dim collection As NotesDocumentCollection Dim doc As NotesDocument 'Date format for the file name FormatDate = Format(Date, "yyyymmdd") 'Set the Original database Set dbOrigin = New NotesDatabase ( "Server1/ACME", "names.nsf" ) Set dbArchive = New NotesDatabase( "", "" ) 'Set the server where new archive copy is created archiveServer$ = "Server1/ACME" 'Build the path and add the date in the file name archiveFile$ = "archive" + FormatDate & dbOrigin.FileName If (Not(dbArchive.Open (archiveServer$, archiveFile$))) Then Set dbArchive = dbOrigin.CreateCopy ( archiveServer$, archiveFile$ ) End If 'Copy all documents from Orgin DB to Archive DB Set collection = dbOrigin.AllDocuments Set doc = collection.GetFirstDocument() While Not(doc Is Nothing) Call doc.CopyToDatabase( dbArchive ) Set doc = collection. GetNextDocument(doc) Wend End Sub

MEMBER FEEDBACK TO THIS TIP

I think this works better:

 Dim session As NotesSession Dim dc As NotesDocumentCollection Dim dbNAB As NotesDatabase Dim dbCurrent As NotesDatabase Dim dbBackup As NotesDatabase Dim docNAB As NotesDocument Dim docTmp As NotesDocument Dim nNameServerActual As NotesName Dim nNameServerNAB As NotesName Dim dbFileName As String Dim processedDocuments As Long On Error Goto backupErrorHandler Print "Starting agent..." Set session = New NotesSession Set dbCurrent = session.currentDatabase processedDocuments = 0 dbFileName = Cstr(Year(Now)) & Cstr(Month(Now)) & Cstr(Day(Now)) Forall nab In session.addressBooks If (nab.isPublicAddressBook) Then Set dbNAB = nab Set nNameServerNAB = New NotesName(dbNAB.server) Set nNameServerActual = New NotesName(dbCurrent.server) If nNameServerActual.abbreviated = nNameServerNAB.abbreviated Then 'the NAB server is the same as the agent server Call dbNAB.Open("", "") Set dbBackup = session.getDatabase("", dbFileName & dbNAB.FileName) If Not(dbBackup.IsOpen) Then Set dbBackup = dbNAB.createCopy("", dbFileName & dbNAB.FileName) End If Else 'the NAB server is other than the agent server Call dbNAB.Open (nNameServerNAB.common, dbNAB.FilePath) Set dbBackup = session.getDatabase(nNameServerNAB.common, dbFileName & dbNAB.FileName) If Not(dbBackup.IsOpen) Then Set dbBackup = dbNAB.createCopy(nNameServerNAB.common, dbFileName & dbNAB.FileName) End If End If If dbNAB.isOpen Then Exit Forall End If End If End Forall If dbNAB Is Nothing Then Print "Domino Directory was not found" Exit Sub End If If Not(dbNAB.isOpen) Then Print "Domino Directory could not be opened" Exit Sub End If If Not(dbBackup.isOpen) Then Print "Backup database could not be opened" Exit Sub End If Set dc = dbNAB.allDocuments If Not(dc Is Nothing) Then If dc.count > 0 Then Set docNAB = dc.getFirstDocument While Not(docNAB Is Nothing) Call docNAB.copyToDatabase(dbBackup) processedDocuments = processedDocuments + 1 Set docNAB = dc.getNextDocument(docNAB) Wend End If End If Print "Documents processed: " & Cstr(processedDocuments) Print "Ending agent..." Exit Sub backupErrorHandler: Print "Error(s) found during agent execution" Exit Sub


—Alfonso F.

Do you have comments on this tip? Let us know.

Related information from SearchDomino.com:

 

This was first published in April 2007

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.