Hi AudioPro,
I'm getting to this discussion late, but wanted to introduce a couple concepts that haven't been discussed (and add my opinions to some that have):
1) There are
significant differences between backing up
DBC's+DBF's and backing up
free DBF tables. With DBC's, I agree fully with Olaf: Backup the whole directory (DBC,DCX,DCT,DBF's,FPT's,CDX's).
Regarding Free Tables:
1) If you use "COPY TO"
without the "WITH CDX" clause, then the resulting DBF's can be backed up, restored, and reindexed with no problem, since the backed-up DBF's weren't marked as having a CDX.
2) If you backup the DBF's "as is", after restoring them you can remove the "This DBF has an attached CDX" marker before trying to USE them...
3) If you don't like hacking DBF headers, then you can create a "stub" CDX (like mentioned above) on a dummy DBF (the DBF structure and CDX contents are irrelevant... VFP doesn't check), and immediately after "USE mytable EXCLUSIVE" opens the DBF with the dummy CDX, just "DELETE TAG ALL" to wipe out the bad CDX.
4) I highly recommend NOT backing up the CDX's because they are so susceptible to corruption, (let alone the fact that they alone can take up more space than all the DBF's). I think that any VFP program that relys on DBF's must have built-in a way to recreate the indexes for those DBF's. Instead of trying to use ATAGINFO to salvage-and-save the info, have the indexes originate from INDEX commands in code... never distribute CDX's with an application.
With DBC's
I don't have the same extent of experience with these, but have one app that has been stable using this system:
Upon installation, a GENDBC script creates the DBC and all related files.
Backup the DBC,DCX,DCT, DBF's & FPT's w/o any alterations.
To Restore:
1)unzip the DBC,DCX,DCT, DBF's and FPT's into a temp location.
2)create one Dummy CDX: for each DBF, in turn, copy that CDX to the appropriate name, USE the DBF, and DELETE TAG ALL. Validate that the tables you care about Do exist.
3)run the GenDBC script to create an empty database of the Current version. (the GenDBC code in the application that is running may be newer than the one that was in the application that created the backup)
4)Open the old database under a different name, loop through all the tables in the new empty DBC, importing the data from the corresponding table from the old DBC. As this happens,
any changes in Schema can be accounted for. I have a stored procedure in each DBC that identifies its version which makes deciding what conversions to do pretty simple.
This system makes it rather easy to improve the Database Schema while still being able to restore backups from previous versions of your program.
- Bill
Get the best answers to your questions -- See FAQ481-4875.