# Friday, February 22, 2008

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.

Possible Improvements

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?

Download the DataBackup Application (approx. 68 KB)

Until next time... VFP Rocks!

Friday, February 22, 2008 2:08:23 PM (GMT Standard Time, UTC+00:00)  #    Comments [5]
Monday, February 25, 2008 7:32:34 PM (GMT Standard Time, UTC+00:00)
Great stuff Craig!

If your looking for some other ideas for the backup...how about being able to email the errors to an email address (or multiple addresses), the ability to do "rolling" backups (i.e. only keep the last 10 or two weeks worht) & have you ever come across a solution to backup the files while they are in use?

Again great work as always!

Jerry
Jerry
Thursday, February 28, 2008 6:26:45 PM (GMT Standard Time, UTC+00:00)
I used VFPCompression.fll to do the same thing in my applications. I wrote an exe in VFP which backups customer data on my server. I also have an ini file that contains the source folder, destination folder and optional additional folders to be included. The program appends the day of the week to the backup so that I get a week's worth of backups for each customer on my server. Since I have multiple servers I put the backups on a different server than the source data. Since all my customers have their own folders inside one "Customer" folder on each server. I simple had the program traverse the folders and produce a backup for each customer. It works great and does not take much time.

Thanks for the great compression utility.
Simon White
Thursday, February 28, 2008 6:30:01 PM (GMT Standard Time, UTC+00:00)
This is an answer to Jerry question about backup up files in use. I open the table in shared mode and copy it to a temp folder and then backup the table in the temp folder. So I can run the backup while the table is in use.
Simon White
Sunday, April 13, 2008 10:26:43 PM (GMT Daylight Time, UTC+01:00)
Craig, it would be wonderfull if you could make a fll for email related stuff, smtp especialy (blat has it's quirks) and maybe pop3 .. that would be good .. just a thought :)
I tried to find something more vfp firendly to retrieve emails but not much luck so far :(

Btw, vfpcompression and vfpconnection are some of the best tools i've had in years ..

You make VFP Rock!
edyshor
Tuesday, August 12, 2008 6:06:45 AM (GMT Daylight Time, UTC+01:00)
95 % OK....
STEVE
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910