Tuesday 13 October 2015

An easy backup routine

It's always wise to make regular copies of all your database files. Whilst there are numerous tools that will do this for you, some of these are expensive, whilst others are overly complex.

If you have a fairly simple backup requirement, i.e. you just want to archive all the files in the database's directory on a regular basis, you might want to consider using a file zipping program, with a command-line interface. This lets you easily zip up all the relevant files with one command, whilst the command itself can be scheduled to run using Windows Task Scheduler or even the Handy Access Launcher.

Using this principal, I like to use WinZip to do my backups for me - the command-line interface is a freely downloadable add-on. Using the WinZip command-line interface takes the following form:

[WinZip command-line zipping executable] [Destination ZIP file] [Files to be zipped] [-switches]

For example:

"c:\program files\winzip\wzzip.exe" "g:\mdb\backup\cd.zip" "f:\mdb\cd\*.*" -ex -P -r -u

There are numerous available switches, described in full in the command-line help file that comes with the add-on. The switches shown in the above example (the only ones I feel it is necessary to use) have the following effects:

  • -ex - sets compression to maximum;
  • -P - causes all folder information specified in the command-line to be stored;
  • -r - recurse into folders (include subfolders). This option requires the -p or -P option;
  • -u - only add files that are new or have changed since the last zip file creation.

A series of these command-line statements can then be written in a single batch file. In this way, I backup seven production databases, and all associated files (e.g. workgroup information files, help files, icon files, splash-screen bitmaps, etc) in a single batch job which is scheduled to run twice a day. In other words, I get regular incremental backups without having to do anything!

I should probably point out a few of the drawbacks of this approach. If a file is in use when the backup runs, WinZip warns you that the zipped version may become corrupted. I haven't had any such problems but if WinZip feels such a warning is appropriate, then it must be possible. Secondly, this method only provides you with incremental backup, i.e. each backup overwrites the previous one. If this is inappropriate for your needs, consider something else. If you just want quick and easy regular backups of your production databases though, this may be for you.

Finally, if you've got a good reason for not using WinZip, you might want to look into 7-Zip which is entirely free (WinZip is shareware), has a superior compression ratio and a command-line interface. Indeed, if anyone does use 7-Zip to perform a backup in the manner described on this page please use the comments below to share the details.

No comments:

Post a Comment