Compare dbs on two servers

What I’m trying to do is remove duplicate databases by comparing two servers. I need to create an array for each server, compare them to find duplicates then compare the documents to know for sure that it’s ok to delete. Here’s what I have so far… but I’m not sure the best way to get a doc count before deleting.

Sub Initialize

Dim session As NotesSession

Dim dbdir1 As New NotesDbDirectory(“Server1”)

Dim dbdir2 As New NotesDbDirectory(“Server2”)

Dim db1 As NotesDatabase, db2 As NotesDatabase

Dim z As Variant

Dim dirlist1() As String, dirlist2() As String

Dim ctr As Integer

On Error Goto ErrHndlr

Open “c:\dblist.txt” For Output As #1

ctr = -1

Set db1 = dbdir1.GetFirstDatabase(DATABASE)

While Not (db1 Is Nothing)

ctr = ctr + 1

Redim Preserve dirlist1(ctr)

dirlist1(ctr) = db1.FileName

Set db1 = dbdir1.GetNextDatabase

Wend

ctr = -1

Set db2 = dbdir2.GetFirstDatabase(DATABASE)

While Not (db2 Is Nothing)

ctr = ctr + 1

Redim Preserve dirlist2(ctr)

dirlist2(ctr) = db2.FileName

Set db2 = dbdir2.GetNextDatabase

Wend

Print #1, “Server1 dbs also on Server2”

For x = 0 To Ubound(dirlist2)

z = Arraygetindex(dirlist1, dirlist2(x), 5)

If Not Isnull(z) Then

Print #1, dirlist2(x)

End If

Next

Exit Sub

ErrHndlr:

Print #1, Cstr(Err) & " " & Error & " " & Cstr(Erl)

Resume Next

End Sub

Subject: Compare dbs on two servers

One might ask why you’re not using replication, but I’m betting there is a reason.

Compare docs in different dbs on different servers…interesting idea. How are the dbs and docs ‘duplicated’ on different servers?

If you’re using an OS file level copy command and forklifting DbA from ServerA to ServerB, then the dbs and docs will share doc ids meaning you can just compare ids between dbs.

If the dbs are created at each site and you do something like a Notes copy/paste of docs or ls to copy the docs between dbs, I’m pretty sure you get unique doc ids in both dbs. At that point, you’d have to figure out a way to do a doc-by-doc/field-by-field comparison of all docs between all dbs; if everything matches, kill off one of the docs or dbs. Ugly, slow, messy…

If I’ve misunderstood the problem you’re trying to solve, please restate it and I’ll take another run at the issue.

Doug