OK William, if my boss asks, I'm going to blame you for the fact that I haven't done any work!
Your suggestion was very helpful but if we used it every time, we would lose a backup each time we ran it when there weren't any changes. So after 3 runs we wouldn't have anything but multiple copies of the most recent database.
So I went looking for more information about batch files. Are you sitting comfortably?
I have now written a batch file that compares the current database with the most recent backup. If they differ, it moves the backups down one and copies the current database into the most recent space. If they haven't changed, it leaves them as they are.
The backups are held in a subdirectory of the main Zionworx directory and are called songs.dbf.bk1, songs.dbf.bk2, etc. (Similarly with songs.dbt).
The batch file runs Zionworx when it has finished the backup check so you can put it in the same directory as Zionworx.exe and point your shortcut at it instead of Zionworx.exe
If you are interested in using it, do the following:
Go to the Zionworx directory (mine is C:\Program Files\Zionworx) and create a subdirectory called "backups"
Copy the script (below) and paste it into notepad. Save this in the main Zionworx directory. I use the filename "zw_backup.bat". MAKE SURE you choose the file type "All files" otherwise notepad will put ".txt" on the end. Don't use Wordpad or (even worse) Microsoft Word because they will almost certainly add things that you don't want.
Double clicking on the file should run it. You will get errors if some or all of the backup files don't exist. You can either ignore them or create some files for it to find.
If you want to use it to run Zionworx, change your shortcut to point to this batch file instead of the Zionworx program. (Right-click on the icon, choose "Properties" and change the target from "Zionworx.exe" to "zw_backup.bat" - or whatever you have called it).
OK, here comes the script . . .
***** START OF SCRIPT (don't include this line) *****
REM This script checks whether the two
REM Zionworx database files are different
REM to the last backup. If they are, it
REM moves the backups down one and copies
REM the current versions to the top
REM backup level.
REM (The .bk1 files are the most recent).
REM It then runs Zionworx.
REM If your shortcut points to this
REM instead of the Zionworx program, it
REM ensures you always have backups of
REM the most recent versions of your
REM song database.
REM If you want to suppress the messages on
REM the screen, take out the REM in the
REM next line. (@echo off)
REM @echo off
REM backupdir is the directory your backups
REM are held in.
set backupdir=.\backups
REM Check for changes in songs.dbt.
REM (fc is file compare. /B is binary)
REM We're not interested in the actual differences,
REM just whether there are any, so send the
REM fc output to null.
fc /B songs.dbt %backupdir%\songs.dbt.bk1 >./nul
set dbtchange=%ERRORLEVEL%
REM Check for changes in songs.dbf
REM (fc is file compare. /B is binary)
REM We're not interested in the actual differences,
REM just whether there are any, so send the
REM fc output to null.
fc /B songs.dbf %backupdir%\songs.dbf.bk1 >./nul
set dbfchange=%ERRORLEVEL%
set /a changes=%dbtchange% + %dbfchange%
REM If one or the other files has changed,
REM back them both up and
REM move previous backups down one.
if %changes% gtr 0 (
rename %backupdir%\songs.dbf.bk3 songs.dbf.bk4
rename %backupdir%\songs.dbt.bk3 songs.dbt.bk4
rename %backupdir%\songs.dbf.bk2 songs.dbf.bk3
rename %backupdir%\songs.dbt.bk2 songs.dbt.bk3
rename %backupdir%\songs.dbf.bk1 songs.dbf.bk2
rename %backupdir%\songs.dbt.bk1 songs.dbt.bk2
copy songs.dbf %backupdir%\songs.dbf.bk1
copy songs.dbt %backupdir%\songs.dbt.bk1
REM Now delete the oldest files.
delete %backupdir%\songs.dbf.bk4
delete %backupdir%\songs.dbt.bk4
)
echo Backups completed. Ready to run Zionworx
REM pause
zionworx.exe
***** END OF SCRIPT (don't include this line) *****
Hope people find this helpful. I'm sure it could be improved but I think I ought to get back to work.
Cheers,
Steve