Ever said, "I wish I could get back to where I was an hour age, or 2 hours ago?" All too often, we simply find it too much trouble to make backups.
There are already several superb articles published about backups, including Tom Cone's article on the learnalpha.com site. However, as a developer, my requirements were slightly different than those previously published. I needed a backup system that allowed me to develop set structures, Xbasic scripts, layouts etc. and if I found myself going down a wrong road, then I needed to be able to revert back to where I was earlier. I needed several generations of backup to enable me to take one, or perhaps two steps backwards.
Whenever I reach what I consider to be a significant landmark in the development, I am able to press a single button that will copy my current "Backup No1" folder files to a folder called "Backup No2" and then copy my current work to "Backup No1" folder. This could easily be extended to further generations if required. If I need to take a step backwards, I then simply use my Windows Explorer to restore the relevant files instead of undoing all the changes that I have made.
Because of the nature of development work, frequently adding/deleting tables, xbasic was not dynamic enough to provide a full maintenance free solution. I started off with writing a small batch file, this is easily done using the Windows Notepad and saving the file as C:Program FilesA5V4Backup.bat
Text for Myprogram is as follows:-
cd"PROGRAM FILESA5V4Myprogram Backup1
copy *.* "c:program filesa5v4Myprogram Backup2
copy *.* "c:program filesa5v4Myprogram Backup1
You will notice that the filenames are preceded with a double quote("). This is the Windows95 convention for handling long filenames. You will now need to add the Myprogram Backup1 and 2 folders that will hold your different generations of backup files.
All that is now left is to include a button or custom menu item, to run the batch file, I use the following Xbasic:-
response=ui_msg_box("Backup","Backup Myprog?",289)
IF response=1 THEN
x = sys_shell("C:Program FilesA5V4BACKUP.BAT ")
ELSEIF response=2 THEN
The ui_msg_box, prevents inadvertent backups if the button is accidentally pressed. The first time the button is used, all Myprogram files are copied to Myprogram Backup1 folder, the second time, Myprogram Backup1 files are copied to the Myprogram Backup2 folder before the Myprogram files are copied to Myprogram Backup1 folder. Think of it like a filing cabinet where all files are moved down a draw each time it is used.
Of course there are improvements that can be made, like if you delete a table, its files are still in the backup folders, easily resolved with a few extra lines in the batch file if this troubles you. The first time that you use the .bat file, the window stays open when the backup is complete, if you rightclick on the Control menu icon in the top left of the window, the Program Properties box appears, there is a Program tab that allows you to "Close on Exit". The file will then run and close itself when complete. You could also write the batch file to only selectively copy the A5 program files, but not the .dbf files if the Data files are very large, and if all you are interested in is working on the program files. I have only used this on Win95, but expect it would work equally well on Win98.
The example shown above is simple, only a few lines of batch file text and Xbasic, takes a few minutes to set up, and could save you lots of grief. When the program is complete and ready for your client, simply remove/hide the button. The batch file will of course also work from a shortcut onto your desktop if you so desire.
Hope some of you can make some use of it
David Priest
Alpha Software Consultant
DP Services, UK