Script to automate eBase upgrade

Post any questions regarding Installing or Upgrading Ebase, including problems starting up the Ebase Xi Server or Designer

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Script to automate eBase upgrade

#1

Postby Segi » Tue Dec 15, 2015 9:11 pm

I am working on a Windows batch file that will automate almost the entire upgrade process when upgrading eBase to a new version and would like to know if someone can help me test it out.

What I need is for someone to follow these steps:

1. Start off with a copy of your eBase folder in c:\ebaseTest for example.
2. Edit my batch file and edit 2 variables to point to the source and destination directories. The source would be the location of the installation files and the destination variable would be c:\ebaseTest in this case.
3. Run the batch file. If any errors are encountered, please let me know so I can fix it then start at step 1 again with the modified batch file.
4. If this step is reached then everything should have upgraded correctly.

Thanks.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Thu Dec 17, 2015 11:35 am

Segi,

I'd be interested in testing this.

Regards
Jon
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#3

Postby Segi » Thu Dec 17, 2015 4:08 pm

Jon,

Here is the first iteration of my script. I am using Windows 10 and utilize a command line utility called xcopy because it can recursively copy directotries.

Please let me know if you run into any issues:

http://pastebin.com/MYECWuRT
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#4

Postby Steve James » Fri Dec 18, 2015 12:30 pm

Hi Segi, this looks interesting.

Have you come across RoboCopy as it appears to be more powerful than XCopy.

For example
/purge
Deletes destination files and directories that no longer exist in the source.
/mir
Mirrors a directory tree (equivalent to /e plus /purge)

This would be good for the documentation folder where the upgrade notes state to delete all files only to copy 90% again. A few other folders follow this approach.

I use Beyond Compare for upgrades as it is nice and visual but would be interested in a script to upgrade.

Thanks
0 x

Hovik
Moderator
Moderator
Posts: 184
Joined: Tue Sep 11, 2007 8:58 am

#5

Postby Hovik » Fri Dec 18, 2015 12:48 pm

Segi,

Thanks for doing this. It's a great first stab at automating the upgrade.

I tried it in my Windows 7 machine, with some success. I suspect xcopy works slightly differently in Windows 7.

The server upgraded ok and I can start it, but a few things not quite right:

1.
Step 19 Removing upgrade=true from UFSSetup.properties
FIND: Parameter format not correct
Step 20 Copying DeploymentMaintenance.eb to SOURCEPATH\Server\Workspace\ebaseSamples\Scheduled_Tasks
Does C:\Ebase_5\Ebase_4_5_3-64_SECURITY_upgrto_V5\Workspace\Shared\Scheduled_Tasks specify a file name or directory name on the target
(F = file, D = directory)?

a) Not sure why it asks this.
b) The echo says ...\Workspace\ebaseSamples\Scheduled_Tasks. It should say ...\Workspace\Shared\Scheduled_Tasks

2. The ufs/doc folder contains all the necessary sub-folders, but they're all empty and all the .htm files are in the ufs folder

3. Same with ufs/WEB-INF/docidx. It's empty and its files are in ufs/WEB-INF

The client upgrade didn't go well.

Both the lib and images folders are empty and their files are in the Client folder.
Also step 9 (lines 106-108) need to copy to properties folder- they copy to the preferences folder instead.

One last comment: despite @echo off at the top, everything is being echoed so difficult to spot problems. I wonder if xcopy by default is verbose.

Thanks again.
Hovik
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#6

Postby Steve James » Fri Dec 18, 2015 1:00 pm

Thanks for reminding me Hovik. We have a number of batch files that run either unattended or output a lot of text. We used to find debuging issues tricky.

You can push the screen output to a log file easily enough as follows.

Code: Select all

>> upgrade.log echo ***** Starting upgrade *****
>> upgrade.log XCOPY /E /Y %SOURCEPATH%\Client\preferences %DESTINATIONPATH%\UfsClient\

blah blah do stuff......

>> upgrade.log echo **** Complete *****
See https://technet.microsoft.com/en-gb/lib ... 90982.aspx for more details.

Thanks
0 x

Hovik
Moderator
Moderator
Posts: 184
Joined: Tue Sep 11, 2007 8:58 am

#7

Postby Hovik » Fri Dec 18, 2015 2:22 pm

Thanks Steve. Automatic upgrades are now a priority, so this is all good stuff.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#8

Postby Steve James » Sun Dec 20, 2015 8:54 am

Hi, I tweaked your batch file to push the output to a text file so the it was easier to spot issues. I had to add the odd /Y (ie force overwrite) to XCOPY statements or the prompt hits the log file and nothing shows on screen. The screen still accepts the input of course.

1 - index file not found - changed to index.htm rather than .jsp

2 - Several statements result in the output asking (F = file, D = directory)?
web.xml; ebaseCache.xml; DeploymentMaintenance.eb
Simply remove the file name and ensure a final slash exists on destination.

eg

Code: Select all

>> %SOURCEPATH%\upgrade.log XCOPY /E /Y %SOURCEPATH%\Server\web_content\WEB-INF\web.xml %WEBAPP%\WEB-INF\
3 - RoboCopy works nicely

Code: Select all

ECHO 4/5 doc directory to %WEBAPP%\doc
>> %SOURCEPATH%\upgrade.log ROBOCOPY %SOURCEPATH%\Server\web_content\doc %WEBAPP%\doc /mir
4 - removing the upgrade=true
cmd is limited, I thought about using vbs or something like it but that made me think that this becomes very Windows based, and of course release specific.

I got it to consistently work by creating a temporary file.

Code: Select all

findstr /v "upgrade=true" %WEBAPP%\WEB-INF\classes\UFSSetup.properties > %WEBAPP%\WEB-INF\classes\UFSSetup.TMP

del %WEBAPP%\WEB-INF\classes\UFSSetup.properties
copy %WEBAPP%\WEB-INF\classes\UFSSetup.TMP %WEBAPP%\WEB-INF\classes\UFSSetup.properties
del %WEBAPP%\WEB-INF\classes\UFSSetup.TMP
I got as far as step 21. This is looking good.

Are Ebase considering an auto upgrader application? That is one that will work on multi platforms and different Ebase releases.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#9

Postby Segi » Mon Dec 21, 2015 4:36 pm

Steve,

I have heard of RoboCopy but my goal was to create a batch file that didn't require any external applications to be installed. I am glad that you guys are making good progress on this automated batch file.

I think that it should be easy to port this script to Linux/Unix/Mac based operating systems. Let me know if you need help with this.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#10

Postby Steve James » Mon Dec 21, 2015 7:21 pm

Hi Segi, RoboCopy was new to me but it is part of standard Windows.
https://technet.microsoft.com/en-GB/lib ... 33145.aspx

It also seems to be a replacement for XCOPY
https://en.wikipedia.org/wiki/Robocopy

It's a good thing that you are getting us to think about automated scripts.

Our production upgrade is very different to our non production upgrade. Some of the upgrade is ignored in production - index, search, doc, getting_started, samples.

I'm going to think about some sort of script that reads a config file and then copies files/folders appropriately. This would allow a common config file for various platforms; an easy way to remove lines depending on user environments; and work across different versions (ie the upgrade approach is common it's just the folders that tend to change).

Thanks
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#11

Postby Steve James » Mon Dec 21, 2015 11:03 pm

Early thoughts on dynamically copying files and folders and having some separation of environment (eg remove lines not required for production), release (just a different system.cfg file provided per release) and platform (equivalent script written for Unix, Mac).

I've written the script in vbs but it could be any number of other mechanisms. The vbs runs robocopy statements and logs it all out to a .log file for later review. It isn't really tested at this stage, I just wanted to prove the point / concept,

3 files.

user.cfg

Code: Select all

SOURCEPATH=C:\Ebase_V501_upgrade
DESTINATIONPATH=C:\ebaseXi454\
WEBAPP=C:\ebaseXi454\UfsServer\tomcat\webapps\ufs
UserJAR=xxx.jar
It would be easy enough to add parameters for the Windows service name or start/stop batch file details so the script can start Ebase to do the upgrade.

system.cfg
Supplied by Ebase, delimited file (currently tab) with 2 options
mirror - equivalent of the delete and create approach
file/wildcard - specific file name or wildcard
The script substitutes SOURCEPATH, DESTINATIONPATH and WEBAPP as read from the user.cfg file

Code: Select all

*.*	%SOURCEPATH%\Server\InternalWorkspace	%DESTINATIONPATH%\InternalWorkspace
*.*	%SOURCEPATH%\Server\samples	%DESTINATIONPATH%\UfsServer\samples
*.*	%SOURCEPATH%\Server\web_content\ebaseConf	%WEBAPP%\ebaseConf
*.*	%SOURCEPATH%\Server\web_content\ebaseInternal	%WEBAPP%\ebaseInternal
*.*	%SOURCEPATH%\Server\web_content\javascript	%WEBAPP%\javascript
*.*	%SOURCEPATH%\Server\web_content\samples\logon	%WEBAPP%\samples\logon
mirror	%SOURCEPATH%\Server\web_content\WEB-INF\lib	%WEBAPP%\WEB-INF\lib
mirror	%SOURCEPATH%\Server\web_content\doc	%WEBAPP%\doc
mirror	%SOURCEPATH%\Server\web_content\WEB-INF\docidx	%WEBAPP%\WEB-INF\docidx
mirror	%SOURCEPATH%\Server\web_content\getting_started	%WEBAPP%\getting_started
index.htm	%SOURCEPATH%\Server\web_content\	%WEBAPP%
search.jsp	%SOURCEPATH%\Server\web_content\	%WEBAPP%
web.xml	%SOURCEPATH%\Server\web_content\WEB-INF\	%WEBAPP%\WEB-INF\
ebasecache.xml	%SOURCEPATH%\Server\web_content\WEB-INF\classes\	%WEBAPP%\WEB-INF\classes\

upgrade.vbs

Code: Select all

StartTime = Timer()
configFile = "user.cfg" 
systemFile = "system.cfg" 

Set fso = CreateObject("Scripting.FileSystemObject") 
Set fConfig = fso.OpenTextFile(configFile) 

Do Until fConfig.AtEndOfStream 
    strLine = fConfig.ReadLine 
    arrFields = Split(strLine, "=") 
    strType = arrFields(0) 
    strValue = arrFields(1) 
    if strType = "SOURCEPATH" then 
       SourcePath = strValue 
    elseif strType = "DESTINATIONPATH" then 
       DestinationPath = strValue 
    elseif strType = "WEBAPP" then 
       WebApp = strValue 
     end if 
   rem to pull out user local JAR files......... 
Loop 
fConfig.Close 

rem got the user config values, now read the file/folder details to copy. 

Set fSystem = fso.OpenTextFile(systemFile) 

Do Until fSystem.AtEndOfStream 
    strLine = fSystem.ReadLine 
    arrFields = Split(strLine, vbTab) 
    strFile = trim(arrFields(0)) 
    strSource = trim(arrFields(1)) 
    strSource = Replace(strSource, "%SOURCEPATH%", SourcePath ) 
    strDestination = trim(arrFields(2)) 
    strDestination = Replace(strDestination, "%DESTINATIONPATH%",DestinationPath) 
    strDestination = Replace(strDestination, "%WEBAPP%",WebApp) 
   rem   WScript.Echo strFile  & vbCRLF & strSource & vbCRLF & strDestination 
   Set oShell=WScript.CreateObject("WScript.Shell") 
   Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject") 
   strLog = "/LOG+:" & Chr(34) & SourcePath & "\upgrade.log" & Chr(34)       
   if strFile = "mirror" then 
      strParms = " /mir " & strLog 
   else   
      strParms = " " & strFile & " /e " & strLog 
   end if
   runWhat =  "robocopy " & strSource & " " & strDestination & strParms
   rem WScript.echo runWhat

   return = oShell.Run(runWhat,4,true)

   rem write each RoboCopy to it's own log and check content.
   rem if return <> 0 then
   rem 		WScript.Echo "Error. Check logs for " & strSource 
   rem end if  
Loop 
fSystem.Close 

EndTime = Timer&#40;&#41;
WScript.Echo "Completed stage 1 in " & FormatNumber&#40;EndTime - StartTime, 2&#41; & " seconds."
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#12

Postby Steve James » Tue Dec 22, 2015 2:29 pm

I tidied up the code (revised in earlier post) and it takes about 40 seconds to sort out the files up to where ufssetup.properties needs the upgrade=true adding.

We do not have any custom jar files so a mirror is right for WEB-INF\lib.

I missed the fact that Java needs to be upgraded but thanks to the wealth of resource in the Forum I sorted that easily enough.
0 x


Who is online

Users browsing this forum: No registered users and 64 guests