Thursday, April 11, 2013

Console command to copy databases

I needed to create database copies (not replicas) of a large number of mail files to an archive server.  Typically you would do this from the Notes Client using File>Application>New Copy.  Enter the server name and then select the folder and perhaps change the file name.  Once you click OK, you're client will be busy as you broker that copy (replication from the client works this way also) to the new location.  If you have a 25mb file to copy it's not a big deal.  If you have a large number of files to copy that range in size from 500mb to 2gb or 3gb, you're going to be busy.

So I searched the web to see if I could find another way to do this.  I figured that they must be a way to create an ADMINP request to copy databases.  I was more than willing to write an application to do that (reusable utilities!).  What I did find surprised me and was so much easier.  There is an undocumented and unsupported feature that has been around for some time (R6) that was exactly what I was looking for. 

First, you need to set an INI variable.  From your console, enter SET CONFIG CLUSTER_ADMIN_ON=1.  This will be turned on immediately (i.e. no server restart needed).  You also don't have to be part of a cluster for this to work.  Once this setting is on, you have a new command to use:  CL COPY.

The parameters for CL COPY is sourceDB targetDB

You have some flexibility with the command as well.  It can be used to create copies, replicas and template copies of your databases.  Below are the different ways to use this command:

To create a non-replica copy of a DB on another server (i.e. new UNID) you would use:
CL copy serverA!!srcDB.nsf serverB!!tgtDB.nsf

To create a replica copy of a DB on another server (i.e. same UNID) you would use:
CL copy serverA!!srcDB.nsf serverB!!tgtDB.nsf REPLICA

To create a design copy of a DB on another server (i.e. new UNID, design and no data) you would use:
CL copy serverA!!srcDB.nsf serverB!!tgtDB.nsf TEMPLATE

To create a non-replica copy of a DB on the same server (i.e. new UNID) you would use:
CL copy srcDB.nsf tgtDB.nsf

You can specify source and target folders as well as the destination name of your database.

Enter the command at your server console.  You can enter multiple commands (i.e. multiple file copies) and they will queue up.  The process is very fast compared to using the Notes Client process.  I copied 17.6gb of data in a little over 1.5 hours.  Not bad.  Plus - I didn't have to babysit the process.  The server took care of it for me.  A nice addition to my admin/developer bag of tricks.

No comments: