Replicating can be a pain when you have numerous databases, even when you have a good Admin tool to help you. A little bit of coding made the task a lot easier for me and saved me dozens of hours of work when doing server infrastructure changes. This tool involves creating a database with the following parts:
Form: Database Replicate-by Filename. This form has the following fields:
- Database Replication by File List Name: [ReplicateListName]
- Comments: [ReplicateListComments]
- Server to Replicate from: [FromServer]
- Server to Replicate to: [ToServer]
- Path to replicate to: [ToPath]
(Leave this blank if you want the files to go to the same path as the original)
- Enter List of Databases: (include path, i.e. mailamable.nsf)
(Note: This will replicate to the same path on the new server.)
- [ReplicateList]
This form also contains a button to run the Database Replicate-by Filename agent. This form is used to create replication lists for the various different replication profiles you may want to setup. You can use them for one time shots then delete them, or save a profile that you may use on a regular basis.
View: Database MaintDatabase Replicate-by Filename. (Note: I use a nested view because I have numerous utilities in this database and this helps me sort them out.) This view shows the following columns to display the following fields:
- List Name: [ReplicateListName]
- Replicate from: [FromServer]
- Replicate to: [ToServer]
This view also contains a button to open the Database Replicate-by Filename form. It is used to display the profiles created using the Database Replicate-by Filename form.
Agent: Database Replicate-by Filename (see included code)
When should agent run?: On Schedule Never
This agent creates and populates a new replica on the receiving server. If you have included a value in the [ToPath] field it will choose that new path to replicate the databases to on the receiving server. If the [ToPath] field is blank, it will replicate the databases to the same path as found on the original server.
With minor modifications, you can setup the agent to run on the server instead of your workstation (as long as the server it is running on has the right to access the database on the 'from' server and create new replicas on the recieving server. I prefer running this utility on an Administrative workstation rather than a server, just for the visibility it gives me into the progress of replication.
Code
Sub Initialize
Dim workspace As New notesuiworkspace
Dim uidoc As notesuidocument
Dim listdoc As notesdocument
Dim db As notesdatabase
Dim db2 As notesdatabase
Dim db3 As notesdatabase
Dim toserver As Variant
Dim fromserver As Variant
Set uidoc=workspace.currentdocument
Set listdoc=uidoc.document
Forall filename In listdoc.ReplicateList
fromserver=listdoc.FromServer(0)
toserver=listdoc.ToServer(0)
Set db = New notesdatabase (fromserver,filename)
If Not db.IsOpen Then Call db.Open (fromserver,filename)
If Not db.IsOpen Then 'cannot open file
Exit Sub
End If
topath=listdoc.ToPath(0)
If topath<>"" Then 'database(s) to replicate to a different folder
temp=""
If Right(topath,1)<>Chr$(92) Then topath=topath+""
For n=Len(filename) To 1 Step -1
If Mid(filename,n,1)=Chr$(92) Then 'found beginning of path, replace with topath
filename=topath+temp
Exit For
End If
temp=Mid(filename,n,1)+temp
Next
End If
Set db3 = New notesdatabase (toserver,filename) 'ensures there is not already a file of that name
If Not db3.IsOpen Then
Set db2 = db.CreateReplica(toserver,filename)
Else
Call db.replicate(toserver)
End If
End Forall
End Sub