KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Copying a segmented data file
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: December 15, 2000

Sometimes when you're going to perform some experimental or diagnostic operation on your database, it's wise to make a copy of your database first. But if it's very large, it can take a long time to copy onto backup media. Now that huge hard disks are inexpensive, it might seem that the easiest thing is to just make a copy of your database into another folder on the same hard drive. But if you do this with a segmented data file, you need to be extremely careful.
Here's an example of what can go wrong. Suppose you make a copy of your original segmented database into another folder on the same hard drive. Then you figure you'll leave your original intact, and do your experimental work with the copy. So you open the structure with the copy of the data file. The big problem is that the path to the remaining segments is stored in the first part of the data file. In this case, the stored path leads it to open the remaining segments of the ORIGINAL data file. If you don't realize this is happening, you can end up in big trouble.
The worst case would be if after completing your testing, you throw away either the original or copied folder. You actually had two valid sets of data files, it's just that the first part of each data file was in the opposite folder. So when you throw away one folder, you've thrown away essential parts of both data files. Once that's done, there's no way to recover what is gone. If you run 4D Tools on the leftover data file parts, it'll tell you there's serious damage, and suggest performing a recover by tags. Trying to combine the leftover data file parts is like trying to join the pieces of two different jigsaw puzzles.
If you want to make copies of your segmented data file onto a hard drive, here's what I recommend:

1. Use a separate hard drive volume to make the copy onto.
2. Always quit the database before copying the data file.
3. As soon as the copying of the segmented data file is completed, lock all the files for the copy of the segmented data file, then unmount the volume with the copy.
4. Never open the copy of the segmented data file. Use the COPY as your backup, and resume work using the ORIGINAL data file.

(If you want to make 4D show the dialogs so you can explicitly select all the data segments, change the path for both the original and the copy. You can either change the name of the folders the segment sets are in, or change the names of all the files in your segmented data files. If you make it so that there are no longer any data segments at the path stored in the first part of the data file, 4D will display the dialogs asking you to specify the location of each segment.)
For the full details on segmenting data files, see Appendix A of the 4th Dimension Design Reference Manual.