Dienstag, 9. August 2011

Synchronizing Database Quotas

Since we heavily rely on database quotas, I find it quite annoying that there's no built-in mechanism to synchronize the quota values (and many other database properties) between different servers in a cluster. Because of that, I wrote a small Lotus Script agent to accomplish that task. Here's the code:

 Option Public
  Option Declare
  Sub Initialize
  Dim dbdir As New NotesDbDirectory("mail01/srv")
  Dim s As New notessession
  Dim db As NotesDatabase
  Dim db2 As NotesDatabase
  Set db = dbdir.GetFirstDatabase(DATABASE)
  While Not(db Is Nothing)
   Print "Processing " & db.Filepath
   If db.sizequota <> 0 then
    Set db2 = s.getdatabase("mail02/srv", db.Filepath , False)
    If Not db2 Is Nothing then 
     If db2.sizequota <> db.sizequota then
      db2.sizeQuota = db.sizequota
      db2.sizewarning = db.sizewarning
      print "Quota for " & db2.filepath & " changed to " & db.sizequota & " Bytes"
      Set db2 = Nothing
     End if
    End If
   End If
   Set db = dbdir.GetNextDatabase
  Wend
 End Sub

Just save the agent-code to a database. Set the agent to run e.g. once a night or once a week, and sign it with an ID that has the right to access all the databases on both servers. The rest should be self-explanatory.

Keine Kommentare:

Kommentar veröffentlichen