Backing Up Data
One of the most important and simplest things a user of a desktop database application can do is to maintain a current backup of the application’s database. However, if the user doesn’t have some sort of software or hardware that makes an automatic backup on a schedule it is usually up to the software developer to implement an easy to use backup feature for the application.
Implementing Data Backup
There are a number of things to consider when implementing a database backup for an application, but usually the VFP developer simply wants the ability to compress VFP data files from a directory on a schedule (such as every night at 3:00 AM) into a zip file that is stamped with the date and time. In the interest of meeting these modest requirements I present an application I call DataBackup.exe.
DataBackup.exe utilizes vfpcompression.fll to generate a zip file of the Visual FoxPro data files contained in a directory. The directory to backup is specified by simply modifying the path in DataBackup.ini. And, with the help of Windows Task Scheduler (yes, it’s available on earlier versions of Windows), DataBackup.exe can easily be run on a schedule. In fact, in the interest of the latter, DataBackup.exe was designed without any GUI elements, though there is a Progress function that you can hook into if you want to implement some progress indication when a backup is in process. In any event, DataBackup.exe is designed to be easily implemented for any VFP application that uses a directory to contain all of the data files.
So, simply bundle DataBackup.exe with your VFP application install. Then have your VFP application write out the path to the Data directory into a DataBackup.ini file where DataBackup.exe resides. Set up a Scheduled Task for it automatically or walk the user through setting up a Scheduled Task that will run DataBackup.exe on a regular schedule.
Note: The Backups (datetime stamped zip files) are generated in the same directory where the DataBackup.exe resides. Also, should DataBackup fail due to an exception being thrown, DataBackup will save the error message information into a file named DataBackup.err. This file can prove useful when trying to diagnose problems when the DataBackup.exe is not generating backups as intended on the user’s machine.
There are a number of things that could be done to enhance DataBackup.exe, such as adding a Restore feature, providing for multiple directories to be specified in DataBackup.ini, allowing for subfolders, allowing the file mask to be modified via the DataBackup.ini to provide for backing up other types of files, allow the user to specify where the backups are created… Any other ideas?
Until next time… VFP Rocks!