Windows backup script

Martin McBride, 2017-04-09
Tags windows backup
Categories windows backup

Note This article was originally written in 2005. Since then, many low cost cloud-based services have appeared which offer off-site backup. Such services provide continuous backup, including keeping old versions of files. For most people this is an easier and more reliable way of doing things. But if you still feel happier with your data on DVD (in addition to being on the cloud) the information here is still valid.

This article describes how to write a simple batch file to automate the process of backing up your source files. The description here assumes you are familiar with the concept of a Windows batch file, and the use of variables in batch files.

The batch file here performs several tasks:

  • Gathering your source files together into a "staging area".
  • Creating file and folder names based on today's date, so each daily backup can have a unique name.
  • Compressing the files into a single ZIP file.
  • Applying strong encryption.

The backup file can be stored on a second hard drive, a DVD etc as you would any other backup. However, since it uses strong encryption you can also archive the file on any spare web space you happen to have access too, creating an off-site backup. For example, you could use the web space which is often included in an ISP account, or you could store the backup in a free online mail account.

Of course, you shouldn't rely on free web space as your only backup! However, as part of your backup strategy it is a great last line of defence against a major disaster which wipes out all your on-site backups.

Why a batch file?

Any backup process benefits from automation - doing it manually is tedious, time consuming and error prone. And because of this you might be less inclined to back up often enough.

There are programs which create backups for you, and that is a valid option you might wish to go for. In my situation, I felt that my requirements were very simple and I didn't want to go through the process of evaluating products, choosing one, deciding whether I could trust it protect with my valuable data, learning how to use it, etc...

I decided I would prefer to use a simple batch file and a couple of well respected open source products to do the compression and encryption, but YMMV, you must decide what is best for you.

Copyright (c) Axlesoft Ltd 2020