ARCHIVE SERIES
PART 25 : BACKUP STRATEGIES TO PREVENT DATA LOSS
This time we will look at how to prevent losing data from your ARCHIVE databases. We put a lot of effort getting data into database files and we can’t afford to lose this work There are certain practices that can greatly reduce the chances of this happening and we will explore some of them now. As I have already mentioned, this will be my final article in this series and the last article of this column. I wrote the first Cable Column in October of 1988 when Bill Jones was the publisher of UPDATE. He thought up the name for the column and got me started. I have had my column in every UPDATE issue since. In July of 1990 I decided to do an extended series on ARCHIVE in the Cable Column. It was a program I enjoyed working with and it seemed somewhat ignored QL users. I thought it deserved a second look. Sometime after that, Frank and Carol Davis took over the magazine and have provided a dependable home for this series ever since. No easy feat. The first Cable Column came out just after the Trump Card was released. It was an exciting time as we started to realize some of the potential of our orphaned computer. Nowadays a stock QL seems a little slow but back then it was memory and disk drives that held us back from taking advantage of the QL’s multitasking operating system.
The Cable Column may end and perhaps other changes are in the wind but I doubt that the QL will fade into obscurity just yet. There there is still a hardcore group of users who are in it for the long haul. Some new developments both in hardware and software are in the pipeline to help us keep up with current technology. My main objective with the ARCHIVE series was to lay out, in some detail, the virtues of ARCHIVE and I have done that in 25 articles. I have compiled the complete set of 25 ARCHIVE articles into a book and disk called :
ARCHIVE MADE EASY
The Complete UPDATE ARCHIVE Series
It is available from FWD Computing (formerly Mechanical Affinity). I still consider ARCHIVE an excellent database system and this book makes a nice tutorial and reference book for anyone interested in ARCHIVE from beginner to advanced user. I have done my best to share my knowledge with others Time constraints now limit my ability to produce articles on a regular basis but I still plan to be an active QL user and sometimes article writer. Writing articles is important to the QL community because when the supply of articles dries up and we stop sharing information, that is when the QL fades from sight.
DIFFERENT KINDS OF DATA LOSS
This article is a general discussion on data protection by using backups with a emphasis on ARCHIVE users. Those that have been following this series might well be writing sophisticated programs by now. It is easy and important to make backing up an integral part of your programs. When I talk about data loss I am taking about major loss. I am not worried if you lose a record or 2 because of a program bug. We are talking about major failures. There are basically three types to consider :
1. A corrupted medium : This is a general kind of data loss that can happen with any computer system and does not depend upon the software used or file type. It can happen to floppy drive disks and hard disks. It is caused by some failure of the medium. The data stored on it can no longer be read. It can happen to an individual file if that is where the bad area is located or to the whole disk if that special area that keeps track of where things are on the disk goes bad. If just one or two files go bad you have a chance to recover most of the disk but if the directory area of the disk is corrupted you can’t find any files on the disk. It is sometimes possible to recover data using special programs that can read the disk sector by sector but you would never want to rely on such a thing as a backup strategy. Only desperate people rely on such things.
When using ARCHIVE you will see the message “Incomplete file transfer” which is error 91 or error 102 when this type of error occurs. First you want to make sure that the disk is not full if you were doing something that was enlarging the space needed on the disk such as adding records to a database or copying a file there (the BACKUP command in ARCHIVE). From ARCHIVE you can use the DIR command to do a directory of the device and see the amount of free space left. If there is free space then there is a good change your disk is corrupted and you will have to deal with it. If the disk is full you still have a problem. If you were adding to a database then you can try to close it and exit but the database may be corrupted end up corrupted as described below.
To protect yourself from this type of error while using a database involves following just one simple rule : Backup your database whenever you change it enough so that you consider it an effort to reenter the information. Depending upon the database this might be after entering or changing 5 records or 20 records or 40 records. It is up to you to decide what an “effort” is.
2. Corrupted Database : This is the second kind of data loss that can happen while using an ARCHIVE database. This error is specific to ARCHIVE and is cause by the way ARCHIVE structures its data. When it happens you will see the message “Wrong file type” which is error 103.
This is the famous corrupted database error that every beginning ARCHIVE users learns the hard way after spending a few hours entering data without backing it up and then promptly losing it. All ARCHIVE user must take precautions to prevent this error no matter how reliable their system. It happens when a database file is opened and a change command (INSERT, APPEND, ALTER, UPDATE, DELETE) is used and for whatever reason the file is not properly closed before ending the ARCHIVE session. When ARCHIVE has a database open and a change is made there is a flag set in the beginning of the database file which tells ARCHIVE the file has not been closed yet and its data is not complete. If ARCHIVE is not able to finish its changes then this flag never gets set back. The next time you try to access the file ARCHIVE refuses to acknowledge it as one of its own even though most of the data is there and perfectly okay. This is definitely a mean and nasty error but it is the price paid for having special features like variable length records. There have been attempts to get around this problem in several ways. One way is to reset the database file flag back with an editor so ARCHIVE will read the file but I found this unreliable and it ignores the fact that there may be some bad data in your database. There is also a commercial program (RECOVER) that will recover the good data in the database but it is very tedious to use and I found it unusable with large databases. You protect yourself against this problem just like you did for the corrupted medium discussed above, frequent backups.
There are several reasons why a database that has been changed does not get closed properly. Some you can control others you can’t. If you QL locks up from time to time then it could lock up during one of these vulnerable times. Also the power could go off. Or you might be multitasking and forget that you have a database in a vulnerable state when you turn the power off. If you use the “CLOSE” or “QUIT” command the database is always properly closed and safe. If you just have a database accessed for “LOOK” then if is safe no matter what you might be doing. It is only when you use the “OPEN” command that you need to be very careful.
3. Lost RAM file – Unlike many other programs, ARCHIVE works with the data in its database. It is not loaded into RAM when accessed. But you can copy your database into RAM at start up and work with it there and then copy it back when done. This works quite well but you have to remember to copy it back from time to time if changes are made so you won’t lose those changes if your QL locks up or power goes off. You never have to worry around corrupted databases if you use this method
PROTECTION STRATEGIES
Naturally the more backups you make the less chance you will have in losing data. But making backups takes time and effort There are several other things to do first. First never have a database “OPEN” more than necessary Always “LOOK” at it until you have to “OPEN” it and then “CLOSE” it and “LOOK” at it when through making changes to it It can become tedious to keep opening and closing it and there is another way. With my Financial program QLerk I never let the user make changes to the main database Instead, I let the user do their work in a temporary Group file that has the same fields as the main database. If the user want to alter a record in the main database they first bring it into the group to work on it. To add a new record is easy as it can just be put in the group. Then when the user requests it, QLerk momentarily merges the changes into the main database. This has proved to be 100% effective because the main database is only vulnerable for a couple of seconds during merging.
I use two backup strategies for databases that use multiple files. First I make a complete backup of the disk from time to time depending how actively the data gets changed. This is done in ARCHIVE by coding the names of the files to be backed up into the program and making it an option. You can do it just as easily by regularly doing a WCOPY from SuperBASIC. You have to stop everything and wait for the backup to be completed. It is usually a good time to do something else for a while. The second type of backup, is to do a quick backup of the most recently changed database I usually provide a menu option in the program to accomplish this task. Remember that you can’t copy a database (using BACKUP) from within ARCHIVE while the database is being accessed. You must first “CLOSE” it, then use the “BACKUP” command to copy it and then access it again. Do the quick backup often and the complete backup from time to time.
WHAT TO DO IF YOU NEED YOUR BACKUP
When you lose a database file or any file the first thing to do is to take your most recent backup and make a copy of it and then use that copy to supply the missing file or files. Never, in your rush to get going again, use the backup itself. Remember you might not understand what caused the data loss in the first place and it might immediately happen again. If this is important data go very slowly and methodically
Start with a fresh disk. Format it and put any files you can from the original on it Next put the latest copy of each file you can’t get from the original from your quick backups. If two databases are interrelated and your backups are from different times you make have to spend some time catching one up with the other. Usually there is a primary database that is most important and will be the one you quick backup most often. The secondary databases change much less often and you can get by with older version of them.
Happy ARCHIVE and may your backups always be freshly made and good luck!