Data base in v2.6

V2.6 Help, If you need help and cannot find it in the FAQ area of this forum feel free to ask the question and someone will reply back.

Moderators: webmaster, Christian, Kuok-Tim, ChrisClark, Forum Support

Data base in v2.6

Postby Tomw » Mon Oct 06, 2008 9:59 pm

As a newy to Zionworx 2.6, how do I back up the data? All I can find is the short cut to data and can't find a block to back up.I want to store the data on a mem stick.
I did back up data on v2.5. :?
Tomw
Junior
 
Posts: 7
Joined: Fri Oct 03, 2008 9:37 pm

Re: Data base in v2.6

Postby ChrisClark » Tue Oct 07, 2008 5:21 am

If you double click on the shortcut it will take you to the location of the data. (That is the easiest way to find it as it is buried a little in the Windows application data directories).

Once there if you go up a folder you will be able to copy the actual data folder as you would have done for previous versions of ZionWorx.
ChrisClark
Site Admin
 
Posts: 196
Joined: Thu May 27, 2004 5:43 am
Location: Auckland, NZ

Re: Data base in v2.6

Postby brainier » Tue Oct 07, 2008 2:03 pm

Make sure that the shortcut points to the correct data location - if you are using Vista and have upgraded Zionworx from 2.5 then the location will have changed. If you are in "c:\program files\zionworx" and using Vista then it is most likely that you are not in the correct location.

Go to File > Preferences > Database and copy the path in the dialog. This is the actual location, and as Chris says just back up the entire folder (but not when Zionworx is running).

The following is a collection of files to make a script to backup the database. Place all files in same folder and replace anything between *** marks with your own values, requires an internet connection as backs up to FTP site (could be customized to a USB key by not running the 'cscript upload.vbs' in File 1 or needed File 3). Finally test this out, do not take my word that this works as I have pulled the below from an older version of my backup script and I am currently working abroad and have no access to my current version.

File 1: _BuildDatabase.cmd [this file is the one that is run to start the backup]
Code: Select all
@echo off
REM (c)Brian Reid - 2008 - Version public2.0
Title Zionworx Song Database Backup
Echo Creating backup of the Zionworx Song Database
echo =============================================
echo.
echo This backup can be restored to any church members computer by
echo visiting ***enter download URL here***. Do not publish this
echo URL to people outside the church or use the database for any
echo other church (this is for copyright reasons)
echo.
echo.
echo ---------------------------------------------
echo.
echo This program operates by opening a number of windows.
echo Please wait until the page says complete before closing.
echo.

cd "%~dp0"
iexpress /N zwData.sed

cscript upload.vbs

echo ** Completed **
pause


File 2: zwData.sed
Code: Select all
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=0
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=Please make sure that the ZionWorx program is NOT currently running and then click Yes to update your software.
DisplayLicense=
FinishMessage=
TargetName=C:\Program Files\ZionWorx\Database Download Builder\zwData.exe
FriendlyName=WRBC ZionWorx Database Updater
AppLaunched=wscript.exe setup.vbs
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="setup.vbs"
FILE1="ZWStyles.ini"
FILE2="bible_data.xml"
FILE3="ZWMargins.ini"
FILE4="ZWSettings.ini"
FILE5="Data.tdbd"
FILE6="FTIndexTable!sys_Id.ind"
FILE7="FTIndexTable!sys_Inr.ind"
FILE8="FTIndexTable.dat"
FILE9="Keywords!sys_In1.ind"
FILE10="Keywords!sys_In2.ind"
FILE11="Keywords.rel"
FILE12="MainTable!sys_Id.ind"
FILE13="MainTable!sys_Inr.ind"
FILE14="MainTable!Title1.ind"
FILE15="MainTable!Title2.ind"
FILE16="MainTable.blb"
FILE17="MainTable.dat"
FILE18="MainTable.mmo"
[SourceFiles]
SourceFiles0=C:\Program Files\ZionWorx\Database Download Builder\
SourceFiles1=C:\Documents and Settings\All Users\Application Data\ZionWorx\2.6\
SourceFiles2=C:\Documents and Settings\All Users\Application Data\ZionWorx\2.6\Data\
[SourceFiles0]
%FILE0%=
[SourceFiles1]
%FILE1%=
%FILE2%=
%FILE3%=
%FILE4%=
[SourceFiles2]
%FILE5%=
%FILE6%=
%FILE7%=
%FILE8%=
%FILE9%=
%FILE10%=
%FILE11%=
%FILE12%=
%FILE13%=
%FILE14%=
%FILE15%=
%FILE16%=
%FILE17%=
%FILE18%=


File 3: upload.vbs
Code: Select all
' (c)Brian Reid - 2008 - Version public2.0
Option Explicit
Dim objFSO, objMyFile, objShell, strFTPScriptFileName
Dim strLocalFolderName, strFTPServerName, strLoginID
Dim strPassword, strFTPServerFolder

'Customize code here to fit your needs
strLocalFolderName = "\Program Files\ZionWorx\Database Download Builder"
strFTPServerName = "***FTP_Server_URL***"
strLoginID = "***FTP_Server_Login***"
strPassword = "***FTP_Server_Password***"
strFTPServerFolder = "***folder/on/ftp/or/web/server/where/you/want/download/backup/from***"

'The follow lines of code generate the FTP script file on the fly,

strFTPScriptFileName = strLocalFolderName & "\FTPUploadScript.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

If (objFSO.FileExists(strFTPScriptFileName)) Then
    objFSO.DeleteFile (strFTPScriptFileName)
End If

Set objMyFile = objFSO.CreateTextFile(strFTPScriptFileName, True)
objMyFile.WriteLine ("open " & strFTPServerName)
objMyFile.WriteLine (strLoginID)
objMyFile.WriteLine (strPassword)
objMyFile.WriteLine ("cd " & strFTPServerFolder)
objMyFile.WriteLine ("binary")
objMyFile.WriteLine ("hash")
objMyFile.WriteLine ("lcd """ & strLocalFolderName & """")
objMyFile.WriteLine ("delete zwData_prev.exe")
objMyFile.WriteLine ("rename zwData.exe zwData_prev.exe")
objMyFile.WriteLine ("put zwData.exe")
objMyFile.WriteLine ("bye")
objMyFile.Close
Set objFSO = Nothing
Set objMyFile = Nothing

'The following code executes the FTP script. It creates a Shell
'object and run FTP program on top of it.
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run ("ftp -s:" & chr(34) & strFTPScriptFileName & chr(34))
Set objShell = Nothing


FIle 4: setup.vbs [this file is used to extract and install the update on download]
Code: Select all
' (c)Brian Reid - 2008 - Version public2.0
OPTION EXPLICIT
On Error Resume Next

Dim pfiles
Dim shell
Set shell = CreateObject("WScript.Shell")

Rem Dim all variables
Dim zwDataDir, zwINIDir, zwSettingsINI
Dim v2point6
Dim crFile, crFileName, bData
Dim filesys

REM Detects from zw setting.ini file

REM - START INSTALL OPTIONS SECTION

REM Get ini file value. Do this with use of the third parameter in GetINIString, the Default parameter, as this is returned if file not found

REM Option1 - Detect v2.6 running on Vista
REM Option2 - XP running v2.6
REM Option3 - XP or Vista running v2.5 on x64 architecture
REM Option4 - XP v2.5 or Vista v2.5 32 bit values

v2point6 = FALSE

if GetINIString("Program Screen", "Database Path", "GoToOption2", "C:\ProgramData\ZionWorx\2.6\ZWSettings.ini") <> "GoToOption2" then
   REM Set Option1
   zwDataDir = GetINIString("Program Screen", "Database Path", "C:\ProgramData\ZionWorx\2.6\Data\", "C:\ProgramData\ZionWorx\2.6\ZWSettings.ini")
   zwINIDir = "C:\ProgramData\ZionWorx\2.6\"
   v2point6 = "TRUE"
   pfiles = "NotUsed"
   zwSettingsINI = "ZWSettings.ini"

elseif GetINIString("Program Screen", "Database Path", "GoToOption3", "C:\Documents and Settings\All Users\Application Data\ZionWorx\2.6\ZWSettings.ini") <> "GoToOption3" then
   REM Set Option2
   zwDataDir = GetINIString("Program Screen", "Database Path", "C:\Documents and Settings\All Users\Application Data\ZionWorx\2.6\Data", "C:\Documents and Settings\All Users\Application Data\ZionWorx\2.6\ZWsettings.ini")
   zwINIDir = "C:\Documents and Settings\All Users\Application Data\ZionWorx\2.6\"
   v2point6 = "TRUE"
   pfiles = "NotUsed"
   zwSettingsINI = "ZWSettings.ini"

elseif GetINIString("Program Screen", "Database Path", "GoToOption4", "C:\Program Files (x86)\ZionWorx\settings.ini") <> "GoToOption4" then
   REM Set Option3
   zwDataDir = GetINIString("Program Screen", "Database Path", "C:\Program Files\ZionWorx\Data\", "C:\Program Files (x86)\ZionWorx\settings.ini")
   zwINIDir = "C:\Program Files (x86)\ZionWorx\"
   v2point6 = "FALSE"
   pfiles = "c:\Program Files (x86)\"
   zwSettingsINI = "settings.ini"

elseif GetINIString("Program Screen", "Database Path", "GoToExit", "C:\Program Files\ZionWorx\settings.ini") <> "GoToExit" then
   REM Set Option4
   zwDataDir = GetINIString("Program Screen", "Database Path", "C:\Program Files\ZionWorx\Data\", "C:\Program Files\ZionWorx\settings.ini")
   zwINIDir = "C:\Program Files\ZionWorx\"
   v2point6 = "FALSE"
   pfiles = "c:\Program Files\"
   zwSettingsINI = "settings.ini"

else
   REM Zionworx's Not Installed
   msgbox "Zionworx 2.5 or 2.6 was not detected on this computer (or version 2.6 has never been run before) and so the update of the songs database cannot proceed.",16,"Zionworx Song Database Installer"
   wscript.quit
   wscript.quit
end if

REM - END INSTALL OPTIONS SECTION

REM zwDataDir must finish with a \ - Check and add if needed
if right(zwDataDir,1) <> "\" then zwDataDir = zwDataDir & "\"

set filesys = CreateObject ("Scripting.FileSystemObject")

REM Root Directory Files
copyFile "ZWstyles.ini",0   
copyFile "ZWsettings.ini",0
copyFile "ZWmargins.ini",0

REM Database (data folder) files
copyFile "Data.tdbd",1
copyFile "FTIndexTable!sys_Id.ind",1
copyFile "FTIndexTable!sys_Inr.ind",1
copyFile "FTIndexTable.dat",1
copyFile "Keywords!sys_In1.ind",1
copyFile "Keywords!sys_In2.ind",1
copyFile "Keywords.rel",1
copyFile "MainTable!sys_Id.ind",1
copyFile "MainTable!sys_Inr.ind",1
copyFile "MainTable!Title1.ind",1
copyFile "MainTable!Title2.ind",1
copyFile "MainTable.blb",1
copyFile "MainTable.dat",1
copyFile "MainTable.mmo",1

REM Replace database path location in settings.ini with value found on this computer and not value in recently restored ini file
'WriteINIString(Section, KeyName, Value, FileName)
WriteINIString "Program Screen", "Database Path", zwDataDir, zwINIDir & zwSettingsINI

REM Delete older database files used in earlier version of ZW from zwDataDir
If filesys.FileExists(zwDataDir & "FTIndexTable.dat") then
   filesys.DeleteFile & zwDataDir & "FTIndexTable.dat"
   filesys.DeleteFile & zwDataDir & "FTIndexTable.id"
   filesys.DeleteFile & zwDataDir & "FTIndexTable.inr"
   filesys.DeleteFile & zwDataDir & "Keywords.in1"
   filesys.DeleteFile & zwDataDir & "Keywords.in2"
   filesys.DeleteFile & zwDataDir & "MainTable.id"
   filesys.DeleteFile & zwDataDir & "MainTable.inr"
   filesys.DeleteFile & zwDataDir & "Title1.ind"
   filesys.DeleteFile & zwDataDir & "Title2.ind"
end if

REM Finished here - generate message
msgbox "The database of songs and the programs settings files have been updated."

Function copyFile(crFileName,bData)
   set crFile = filesys.GetFile(resolvePath(crFileName))
   if bData = 1 then
      crFile.Copy(zwDataDir & crFileName)
   else
      if v2point6 = "FALSE" then
         REM If running v2.5 rename the ZW___.ini files to ___.ini
         crFile.Copy(zwINIDir & mid(crFileName,3))
      else
         REM Running v2.6, so copy INI files to zwINIDir folder
         crFile.Copy(zwINIDir & crFileName)
      end if
   end if
End Function

Function resolvePath(path)
   Dim fso    : Set fso = CreateObject("Scripting.FileSystemObject")
   Dim wshell : Set wshell = CreateObject("WScript.Shell")
   
   Dim here : here = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\") - 1 )
   
   resolvePath = fso.GetAbsolutePathName(fso.BuildPath(here, path))
End Function

Function browseFolder(zwDataDir)
   set oShell= createobject("shell.application")

   sMsg= "Select a Folder"
   cBits= 1
   xRoot= 17

   On Error Resume Next
       dim oBFF: set oBFF= oShell.browseForFolder(0, sMsg, cBits, xRoot)
       if err then err.clear: wscript.quit
   on error goto 0

   if not isobject(oBFF) then wscript.quit
   if not (lcase(left(trim(typename(oBFF)), 6))="folder") then wscript.quit

   REM Output   

   On Error Resume Next
       sFolder= oBFF.parentFolder.parseName(oBFF.title).path
       fErr= cbool(err)
   on error goto 0
   if fErr then
       sFolder= oBFF.title
       iColon= instr(sFolder, ":")
       if (iColon<2) then wscript.quit
       sFolder= ucase(mid(sFolder, iColon -1, 2)) & "\"
   end if

End Function

'Work with INI files In VBS (ASP/WSH)
'v1.00
'2003 Antonin Foller, PSTRUH Software, http://www.motobit.com
'Function GetINIString(Section, KeyName, Default, FileName)
'Sub WriteINIString(Section, KeyName, Value, FileName)


Function GetINIString(Section, KeyName, Default, FileName)
  Dim INIContents, PosSection, PosEndSection, sContents, Value, Found
 
  'Get contents of the INI file As a string
  INIContents = GetFile(FileName)

  'Find section
  PosSection = InStr(1, INIContents, "[" & Section & "]", vbTextCompare)
  If PosSection>0 Then
    'Section exists. Find end of section
    PosEndSection = InStr(PosSection, INIContents, vbCrLf & "[")
    '?Is this last section?
    If PosEndSection = 0 Then PosEndSection = Len(INIContents)+1
   
    'Separate section contents
    sContents = Mid(INIContents, PosSection, PosEndSection - PosSection)

    If InStr(1, sContents, vbCrLf & KeyName & "=", vbTextCompare)>0 Then
      Found = True
      'Separate value of a key.
      Value = SeparateField(sContents, vbCrLf & KeyName & "=", vbCrLf)
    End If
  End If
  If isempty(Found) Then Value = Default
  GetINIString = Value
End Function

Sub WriteINIString(Section, KeyName, Value, FileName)
  Dim INIContents, PosSection, PosEndSection
 
  'Get contents of the INI file As a string
  INIContents = GetFile(FileName)

  'Find section
  PosSection = InStr(1, INIContents, "[" & Section & "]", vbTextCompare)
  If PosSection>0 Then
    'Section exists. Find end of section
    PosEndSection = InStr(PosSection, INIContents, vbCrLf & "[")
    '?Is this last section?
    If PosEndSection = 0 Then PosEndSection = Len(INIContents)+1
   
    'Separate section contents
    Dim OldsContents, NewsContents, Line
    Dim sKeyName, Found
    OldsContents = Mid(INIContents, PosSection, PosEndSection - PosSection)
    OldsContents = split(OldsContents, vbCrLf)

    'Temp variable To find a Key
    sKeyName = LCase(KeyName & "=")

    'Enumerate section lines
    For Each Line In OldsContents
      If LCase(Left(Line, Len(sKeyName))) = sKeyName Then
        Line = KeyName & "=" & Value
        Found = True
      End If
      NewsContents = NewsContents & Line & vbCrLf
    Next

    If isempty(Found) Then
      'key Not found - add it at the end of section
      NewsContents = NewsContents & KeyName & "=" & Value
    Else
      'remove last vbCrLf - the vbCrLf is at PosEndSection
      NewsContents = Left(NewsContents, Len(NewsContents) - 2)
    End If

    'Combine pre-section, new section And post-section data.
    INIContents = Left(INIContents, PosSection-1) & _
      NewsContents & Mid(INIContents, PosEndSection)
  else'if PosSection>0 Then
    'Section Not found. Add section data at the end of file contents.
    If Right(INIContents, 2) <> vbCrLf And Len(INIContents)>0 Then
      INIContents = INIContents & vbCrLf
    End If
    INIContents = INIContents & "[" & Section & "]" & vbCrLf & _
      KeyName & "=" & Value
  end if'if PosSection>0 Then
  WriteFile FileName, INIContents
End Sub



'Separates one field between sStart And sEnd
Function SeparateField(ByVal sFrom, ByVal sStart, ByVal sEnd)
  Dim PosB: PosB = InStr(1, sFrom, sStart, 1)
  If PosB > 0 Then
    PosB = PosB + Len(sStart)
    Dim PosE: PosE = InStr(PosB, sFrom, sEnd, 1)
    If PosE = 0 Then PosE = InStr(PosB, sFrom, vbCrLf, 1)
    If PosE = 0 Then PosE = Len(sFrom) + 1
    SeparateField = Mid(sFrom, PosB, PosE - PosB)
  End If
End Function

Function GetFile(ByVal FileName)
  Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")
  'Go To windows folder If full path Not specified.
  If InStr(FileName, ":\") = 0 And Left (FileName,2)<>"\\" Then
    FileName = FS.GetSpecialFolder(0) & "\" & FileName
  End If
  On Error Resume Next

  GetFile = FS.OpenTextFile(FileName).ReadAll
End Function

Function WriteFile(ByVal FileName, ByVal Contents)
 
  Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")
  'On Error Resume Next

  'Go To windows folder If full path Not specified.
  If InStr(FileName, ":\") = 0 And Left (FileName,2)<>"\\" Then
    FileName = FS.GetSpecialFolder(0) & "\" & FileName
  End If

  Dim OutStream: Set OutStream = FS.OpenTextFile(FileName, 2, True)
  OutStream.Write Contents
End Function

Brian Reid
Woodstock Road Baptist Church, Oxford, UK
http://wrbc.org.uk/
brainier
Expert User
 
Posts: 325
Joined: Sun Oct 02, 2005 7:51 pm
Location: Oxford, UK.

Re: Data base in v2.6

Postby Tomw » Thu Oct 09, 2008 8:50 pm

Thank you Chris, I have found the data file and backed it up! :D
Thank you Brainier for your solution, but I'm afraid the process is out of my computer knowledge capabilities.
Tomw
Junior
 
Posts: 7
Joined: Fri Oct 03, 2008 9:37 pm


Return to Zionworx V2.6 Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron