Database Backup

Post your wish lists for new versions of the software.

We cannot do everything but if we know what people want it make life easier.

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

Database Backup

Postby AliBy » Mon Oct 18, 2004 9:37 am

A simple yet - I think - crucial feature would be a automatic backup option.
One would specify:
1. The location (directory or network path etc.)
2. The backup method (i.e. on closing or opening of Zionworx, or every x minutes, everytime a new song is added to the database etc)
3. How many database histories you want (keep the last 3 databases)
Alistair Baty
Urban Life Church
Midrand
South Africa
User avatar
AliBy
Senior
 
Posts: 89
Joined: Mon Oct 27, 2003 12:20 pm
Location: South Africa

Database backup

Postby kck » Mon Oct 18, 2004 1:20 pm

I wondered about this as well.

I wondered whether I could come up with a script that would backup the database and then run Zionworx. I could then point the desktop shortcut at the script instead of the program I could ensure that we had a recent backup every time the program was run.

It would be good to check the latest backup against the previous one so you didn't get an unecessary backup every time.
It would also be good to specify how many backups to keep and perhaps datestamp the file.

There's no reason it has to be written into the main program. A separate script would do.

I tried doing it though. Partly through lack of time and partly through unfamiliarity with Windoze scripting.
Now if it were UNIX . . . :D

Does this sound like a reasonable solution?

Steve
kck
Senior
 
Posts: 57
Joined: Mon Jul 12, 2004 3:39 pm
Location: Cumbria, UK

Postby Christian » Mon Oct 25, 2004 12:17 pm

Hi there,

Isn't it annoying how the most logical things are also the things that we sometimes overlook most easily? Can't believe I never thought to do this in v2.0, but we'll try to build it into v3.0.

But in the meantime there's no reason why somebody couldn't write a batch file to run that would do a basic backup routine - any offers?
User avatar
Christian
Site Admin
 
Posts: 390
Joined: Tue Jun 24, 2003 3:33 pm
Location: Coventry, U.K.

Database backup

Postby kck » Mon Oct 25, 2004 3:23 pm

I tried doing it though. Partly through lack of time


That should have said "I HAVEN'T tried doing it . . ."
I really must reed my poasts more closely before submitting them

Steve
kck
Senior
 
Posts: 57
Joined: Mon Jul 12, 2004 3:39 pm
Location: Cumbria, UK

Postby Williamting » Tue Oct 26, 2004 9:25 am

Try this a very simple and no frill script:

del backup\songs_3.dbt
del backup\songs_3.dbf

ren backup\songs_2.dbf songs_3.dbf
ren backup\songs_2.dbt songs_3.dbt

ren backup\songs_1.dbf songs_2.dbf
ren backup\songs_1.dbt songs_2.dbt

copy songs.dbt backup\songs_1.dbt
copy songs.dbf backup\songs_1.dbf

Pause
zionworx.exe

The above program is my five minutes worth of work, nothing fanciful but it works. Here is what you have to do:

Copy the above lines from the first del to zionworx.exe onto a xxx.bat file in the zionworx directory. xxx is the filename of the script.

To run, you may create a shortcut and place it on the desktop. Just double click on the shortcut to activate. The script will first backup your db, pause for you to hit enter (so that you can see error messages) and then run Zionworx.

As I said earlier, there is nothing fanciful. So, the first two runs will produce errors because it is trying to delete/rename non existence files.

One last point, make sure that the directory called "backup" is created under zionworx directory.

Send me an e-mail and I will send you the script and the shortcut.

Best regards,
William

p/s Ed, I am wondering if there is a mechanism for me to distribute this simple script and shortcut through this forum.
Williamting
Most Senior
 
Posts: 146
Joined: Sat Sep 13, 2003 5:11 am
Location: Miri, Malaysia

Database backup

Postby kck » Tue Oct 26, 2004 2:57 pm

OK William, if my boss asks, I'm going to blame you for the fact that I haven't done any work! :D

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
kck
Senior
 
Posts: 57
Joined: Mon Jul 12, 2004 3:39 pm
Location: Cumbria, UK

Postby Williamting » Tue Oct 26, 2004 3:15 pm

ok, Steve. All blame shall be on me and all glory shall be to God!
:D

Your script is indeed much better. I will take yours.

With blessings,
William
Williamting
Most Senior
 
Posts: 146
Joined: Sat Sep 13, 2003 5:11 am
Location: Miri, Malaysia

Database backup

Postby kck » Tue Oct 26, 2004 4:25 pm

You're very kind.
As a mere junior on this forum and with very limited windows scripting experience, (read "none"), I posted this with some trepidation. It is very encouraging to receive such positive feedback from an advanced user.

Thanks again,
Steve
kck
Senior
 
Posts: 57
Joined: Mon Jul 12, 2004 3:39 pm
Location: Cumbria, UK


Return to Zionworx Wish List

Who is online

Users browsing this forum: No registered users and 4 guests

cron