Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

Archive old documents from a production database.

Hello all experts,

Let me briefly explain what I have here.
I have a production database on a server which contains documents ranging from year 2001 to 2004 and more.
What I need to do now is archive the documents that are not of the current year(2004) into another database(archive_year.nsf) and delete the archived documents from the production database.
I am not the server administrator.
Can somebody please tell me what would the server administrator need to do for this archiving? Will he need to create a new empty database then have someone code an agent to run on the production server that will select the documents and copy it to the new database?
Or are there some other steps? I need detailed step-by-step instructions if possible as I need to do a documentation on this. Thanks for the help and let me know if more details are needed.
0
SadCase
Asked:
SadCase
  • 13
  • 11
  • 2
1 Solution
 
madheeswarCommented:
First Create a view with  a selection forumla: View Name: uploadview
Select Form="yourFormname" & @Year(@Created)!=@year(@today)

The above will display documents which are not creatd in 2004.

Now, create an agent:
Agent Name: UploadDocs
Select Lotus Script

Sub Intialize
Dim ss as new notessession
dim db as notesdatabase
dim view as notesview
dim doc as notesdocument
dim updoc as notesdocument
dim updb as notesdatabase

set db=ss.currentdatabase
set view=db.getview("uploadview")
set doc=view.getfirstdocument
set updb=ss.getdatabase(db.server,"archive_year.nsf")
while not doc is nothing
set updoc=updb.createdocument
Call doc.CopyAllItems( updoc )
call updoc.save(true,true)
set doc=view.getnextdocument(doc)
wend
End sub


Copy a new database on the server from the database and name it as archive_year.nsf
0
 
madheeswarCommented:
Once the above is Run, then run the below agent to delete docs. Ofcourse we can delete docs from above code. To simplify things I am creating anotehr agent to delete docs.

NOTE: PLEASE CREATE A BACKUP COPY BEFORE YOU RUN THE ABOVE AGENT .

Sub Click(Source As Button)
      Dim notesuiworkspace
      Dim uidoc As notesuidocument
      Dim session As New NotesSession
      Dim db As NotesDatabase
      
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim doc1 As NotesDocument
      
      Set db = session.CurrentDatabase
      Set view=db.GetView("uploadview")
      
      If Not view Is Nothing Then
            Set doc=view.GetFirstDocument
      'Remove existing search Results from the personal folder
            While Not doc Is Nothing
                  Set doc1=view.GetfirstDocument
                                                Call doc1.remove(True)
                  'Call doc1.Removefromfolder("uploadview")
                  Set doc=view.GetNextDocument(doc1)
            Wend
      End If
      
            
End Sub
0
 
SadCaseAuthor Commented:
Hmm...... I need the archive database to be functioning like the production database except that it would have old documents while the production database contains the current year document.
Because after archiving the documents, I still need to create additional forms and views on the archive database so that the documents can still be accessed from the web(only difference is that now it resides in another database).
Reason why I'm needing to archive is so that the production server will be more efficient(only containing current year documents).
I'm guessing I will need to create a new copy of the database and choose copy design elements only?

Sorry for not being clearer in my question.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SadCaseAuthor Commented:
I have many different forms and views in the production database and if I make a new copy of it with design elements intact, will I need to create agents to copy the documents to the different forms and views?
0
 
madheeswarCommented:
just run the above agents from the production database and it will take care.
Creating a new copy with design elements is fine.


or you can schedule the above agents to run daily. And the first Agent at 1AM and the second agent at 3AM daily.
0
 
SadCaseAuthor Commented:
Hi madheeswar,

I tried running the UploadDocs script but I keep getting a "archive_year.nsf database is not opened" error. I think its because the archive_year.nsf database resides in the local computer. Its not on the same server as the production database. Is there anyway to change the code so that it will copy to a database on the local drive?

Thanks
0
 
madheeswarCommented:
Instead of this:
set updb=ss.getdatabase(db.server,"archive_year.nsf")

use:
set updb=ss.getdatabase("","archive_year.nsf") 'This local database should reside on Notes data directory.
0
 
SadCaseAuthor Commented:
Hi Madheeswar,

I ran the script but nothing seem to have been copied over.
Started running agent 'UploadDocs' on 09/22/2004 03:33:08 PM
Running on all documents in database: 4380 total
Found 4380 document(s) that match search criteria
Ran LotusScript code
Done running agent 'UploadDocs' on 09/22/2004 03:34:24 PM

For the view, I changed the selection formula to :
SELECT @Contains(ID;"ABC123") & (Date < [01/01/2004]) where Date and ID are fields. Right now, there's only one column in the view with the header #
I changed the formula because the production database I am using right now is basically a copy of the actual production so I wasnt sure if the @Created date will be correct.
0
 
SadCaseAuthor Commented:
I also did not specify the form in the view selection formula. I need to copy all documents from all forms/views that matches the Date<1/1/2004 criteria over to the archive database.
0
 
madheeswarCommented:
is the view displaying any documents?

And enable Lotus Script debug and look in the loop. It should come into the loop.
0
 
SadCaseAuthor Commented:
The view only has a single column # and it contains numbers from 1 to 1654(1654 documents that match the SELECT @Contains(ID;"ABC123") & (Date < [01/01/2004])  condition i think)
I have no idea how to use the debugger to check whether the code went into the loop but when I clicked continue, the debugger didnt go to any line and stop it just completes running but no documents are copied.
The matches done by the agent is wrong too because it found 4380 documents which is all the documents in the database.
Could this be due to the agent restriction set to 1 ?
0
 
madheeswarCommented:
To enable Debugger:
File->Tools->DebugLotusScript

and don't click on Continue. click on StepNext
or Place this line in between the loop :
k=k+1
Print "Processing: " & cstr(k)

And before loop:
k=0

U can see the Processing and no in the status bar of Notes client.
0
 
madheeswarCommented:
And to confirm, make this type of selection formula:
Since it is a etsting environment:

Select Form="Formname"

this will display all the docs. Then run the agent.
0
 
SadCaseAuthor Commented:
OK this time I used the Debugger when running the agent and clicked "Step Into" instead of Continue. The code goes down line by line then keeps on looping in the while loop but nothing gets created.

The match is still 4380 so I went to the agent's Document selection formula window and added 2 conditions, both conditions by field:
Date is before 01/01/2004 AND field ID contains ABC123
After I added this, the agent matches becomes 1654 which is the same as the view but nothing is copied
0
 
SadCaseAuthor Commented:
When i add Select Form="Formname" in the view's selection formula it becomes empty.
0
 
madheeswarCommented:
What is the status bar displaying?
did u kept my Print statements as I said?
0
 
madheeswarCommented:
Selectin formula should be:

Select Form="AnyofYourFormName"
0
 
madheeswarCommented:
Just now found a good code from Qwaletee:
Dim s as new notesSession

Dim source as notesDatabase
Set source = s.currentDatabase

Dim documents as notesDocumentCollection
Set documents = source.unprocessedDocuments

Dim document as notesDocument
Set document = documents.getFirstDocument

Const LOCAL = ""
Dim destination as new notesDatabase ( LOCAL , "DESTINATION.NSF" )

Do Until document is nothing
  document.copyToDatabase destination
  set document = documents.getNextDocument ( document )
Loop

the above code is to copy to destinatin db.
Follow the URL:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_20916805.html
0
 
SadCaseAuthor Commented:
Hi Madheeswar,

with your print code, the status bar prints Processing : 1 2 3 and so on while lopping but still, nothing gets copied. When I tried Qwaletee's code, nothing gets copied too.
0
 
madheeswarCommented:
then it is copying perfectly to the archive database.
check the archive_year.nsf

and try this modified code from Q:
Dim s As New notessession
      Dim source As notesDatabase
      Set source = s.currentDatabase
      Dim view As notesview
      Dim document As notesDocument
      Set view=source.GetView("Uploadview")
      Set document =view.getFirstDocument
      
      Const LOCAL = ""
      Dim destination As New notesDatabase ( LOCAL , "archive_year.NSF" )
      k=0
      Do Until document Is Nothing
            k=k+1
            Print "Processing: "&Cstr(k)
            document.copyToDatabase destination
            Set document = view.getNextDocument ( document )
      Loop


0
 
SadCaseAuthor Commented:
Hi Madheeswar,

I gotta leave for now will get back to you in 15 hours' time. By the way I realised the documents were indeed copied correctly, silly me. I was looking in the view which contained only 2004 documents no wonder I kept seeing nothing.
0
 
lianaizhouzhiruoCommented:
oK, let's see if I got this correct.
To create an archive database from my production one, I need to first:
1 Get the server administrator to create a new copy of the database and copy design elements only.
2 Delete unneeded forms and views from this new Archive database.
3 Create an agent that will copy all documents that meets a specified criteria over from the Production to the archive. Your code does that but I realised there was a simpler way to do it without needing lotusscript or creating a new view. Just create an agent in the Production with simple actions and it will do the same thing as your code although LS seems to be faster.
4 After copying the documents over to the Archive, create an agent that will delete away the copied documents from the Production. This can also be done with an agent that uses simple action.
5 Final step would be to create new forms and views for users to view documents in this Archive database.

Are the above steps correct? Am I missing something?
0
 
madheeswarCommented:
lianaizhouzhiruo ,
to whom you are refering the steps?

I think SadCase got what he/she looking.

question is closed.

If u have simple solution, please provide it with steps(including agents) and take the above points.
0
 
lianaizhouzhiruoCommented:
RE: Madheeswar

Just summing things up. I dont expect to get points for that :) You got SadCase through since the start. Points' all yours
0
 
madheeswarCommented:
lianaizhouzhiruo,
THEN i WILL CORRECT YOUR STEPS.
1 Get the server administrator to create a new copy of the database and copy design elements only.
>> if the user have rights, then no need to contact admin. Else the above step applies.
2 Delete unneeded forms and views from this new Archive database.
>> If it is an archive database, it means, everything will be in tact. Including views, forms. even maintaing unneeded views doesn't create much problem. so, I will exclude this point.
3 Create an agent that will copy all documents that meets a specified criteria over from the Production to the archive. Your code does that but I realised there was a simpler way to do it without needing lotusscript or creating a new view. Just create an agent in the Production with simple actions and it will do the same thing as your code although LS seems to be faster.
>> My idea of writing LS is to provide faster solution. Ofcourse Simple Actions will be faster compared to LS(According to documentation).
4 After copying the documents over to the Archive, create an agent that will delete away the copied documents from the Production. This can also be done with an agent that uses simple action.
>> Yes.
5 Final step would be to create new forms and views for users to view documents in this Archive database.
>>it depends on user requirement. If they want same look and feel, then no need to change or create new design elements in Archive copy.

Thats it.
0
 
SadCaseAuthor Commented:
Hi,

Thanks Madhesswar for help and lianaizhouzhiruo for summary. I think the last 4 posts just about solve my question! Thanks to both of you and madheeswar gets an extra something called points lol
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 13
  • 11
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now