Solved

Windows Scripting to execute BUTIL command for PSQL on multiple files based on conditions containing wildcards

Posted on 2008-10-03
9
866 Views
Last Modified: 2013-12-25
We need to use a utility from Pervasive SQL to put data files into continuous operations mode for backup purposes. The following works to put "file" into continous mode, however, the command does not support wildcards.

butil -startbu C:\data\files\file

Their utility does not support wildcards. We need to put any file ending with EXA into continuous mode, and "butil -startbu C:\data\files\*EXA" will return a syntax error.

The butil utility supports using a text file as a list, so that might help up work around this limitation. The butil only properly supports absolute paths, not relative. Initially my idea was to run a "dir *EXA /B > temp.txt" and use that file as a list, however it does not output absolute path names.

Would be best way to do this be with a batch file or a vb script? I am not too familiar with VB scripts.
The command syntax is as follows:

BUTIL -STARTBU <sourceFile | @listFile> [/UID<name> </PWD<word>> [/DB<name>]]

Open in new window

0
Comment
Question by:bradl3y
  • 4
  • 3
  • 2
9 Comments
 
LVL 28

Expert Comment

by:Bill Bach
ID: 22637084
Simply:
    DIR *.EXA /s /b <files.lst
Then, edit the resulting file to remove any files that you do not want, or to add any others that you do.  Finally, call BUTIL with a command like this:
    BUTIL -STARTBU @files.lst

More detail, if this gets used as a solution:

A good white paper on Continuous Operations mode can be found here:
    http://www.goldstarsoftware.com/press.asp
(Get the white paper on obtaining proper database backups.)

In short, the ways to do this include:
1) Use the Pervasive Backup Agent.  Supported on PSQLV8 and newer, this automatically  puts any open files into continuous mode for backup.  
2) Use BUTIL with a list file.  Doing this requires that you create a list file first, as it looks like you are trying to do, but the pathnames must be "engine-relative".  You can create this list with the aforementioned command easily enough.
3) Use a command-line script.  Something like this would also work,
    for %f in (*.EXA) do BUTIL -STARTBU %f
Although it is not as "correct":, since each file gets put into continuous mode independently, and related files may have different timestamps, leading to data issues.
4) Use a program to do the same thing.  A tool from Goldstar Software called GSBackup can help automate this process, and can even accept *.* as an option, as it examines each file before putting it into ContOps mode for you.
0
 
LVL 6

Author Comment

by:bradl3y
ID: 22637111
I found that using the /S flag with dir will output full path names.

There is still a problem in that if there is any entry in the list which fails, the entire command fails. In this case, it seems some of the files arent MicroKernel data files, causing the command to fail.

There is no way to tell from the file name that i know of which are microkenrel files. The best way to workaround this that i can think of would be to create a script to run the command on each entry in the list individually. I would not know how to create a batch file to do that.

Is there a better solution that anyone can think of or can someone show me how such a script would work? To read a file line by line and put the contents of that line into a command?
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 300 total points
ID: 22637185
You are correct -- all files in the list MUST be present, and all MUST be Btrieve files.  Otherwise the command fails.  The tool HoldOpen, available at www.goldstarsoftware.com/tools.asp accepts the SAME file as BUTIL, and it reports which files fail to open properly.  You can use this to quickly pare down thye list to only those files that are "real" database files.

If you choose to run a scriupt to do each file separately, please remember that the files will no longer all share the same "snapshot".  For example, in a banking scenario, this means that the Savings accounts file could be different by one or more minutes from the Checking Accounts file.  If someone did a transfer from one to the other during the backup window, and you had to rely on this backup, you might find that the money was pulled out of one account (because that files was snapshotted AFTER the transfer), but never added to the other (because that file was snapshotted BEFORE the transfer).  I admit that the time difference may be small, but just keep this in mind.

To answer your last question, the tool MakeBAT can be found at the same location.  A command like this would also work for you:
    MAKEBAT "BUTIL -STARTBU " <files.lst >batchscript.bat


Luckily, no matter what you do, using BUTIL -ENDBU /A will close ALL files out of ContOps mode.
0
 
LVL 7

Assisted Solution

by:Hubasan
Hubasan earned 200 total points
ID: 22637325
Hi bradl3y,

If you want to run your command on each individual file that has EXA extension in that particular folder you can use this script:
' List All the Files in a Folder

Set oWS = CreateObject("wscript.shell")
 

strComputer = "."
 

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 

Set colFiles = objWMIService. _

    ExecQuery("Select * from CIM_DataFile where Drive = 'C:' and Path = '\\data\\files\\'")
 

For Each objFile in colFiles

	sFilePath = objFile.Name

	sExt = ".exa"

	If InStr(sFilePath, sExt) Then

		oWS.Run "%comspec% /c BUTIL -STARTBU " & sFilePath & " >> C:\Logfile.log",2,True

	End If

Next

Open in new window

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 7

Expert Comment

by:Hubasan
ID: 22637374
One more thing. Please modify the script in this line to tell it where exactly your BUTIL executable is:

oWS.Run "%comspec% /c BUTIL -STARTBU " & sFilePath & " >> C:\Logfile.log",2,True

Modifiy above line just before "BUTIL" to include the path to the utility (example would be C:\Utilities\BUTIL)
so if that was the path your entire line would be like this:

oWS.Run "%comspec% /c C:\Utilities\BUTIL -STARTBU " & sFilePath & " >> C:\Logfile.log",2,True
0
 
LVL 6

Author Comment

by:bradl3y
ID: 22682015
Sorry for the lack of response. I have had a chance to try these suggestions yet . The method involving HoldOpen seems like the most proper way (other than using the backup agent which isn't working). I will give that a try.
0
 
LVL 28

Expert Comment

by:Bill Bach
ID: 22682805
Did you try the Backup Agent?  If so, what problems did you have?  
0
 
LVL 6

Author Comment

by:bradl3y
ID: 22688724
Once backup agent was enabled, our software would throw errors when users tried to use it, relating to not being able to access certain files. From what the support of our software company said, they said the Backup Agent must be having files with data files being created after the backup starts. The software apparently creates many temporary data files, and it seems Backup Agent, while running, does not handle newly created files properly. I spent much time with their support trying to resolve this, but was unable to.
0
 
LVL 28

Expert Comment

by:Bill Bach
ID: 22689021
Depending on your database version, you may be able to leverage the "black list" capabilities of BA1.1.  However, I suspect that Pervasive's tech support would have already suggested this, and perhaps it doesn't work for you due to the file names or directories they are using for temp files.  Some applications just don't like the way BA messes with them, to be sure.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Read about achieving the basic levels of HRIS security in the workplace.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now