Bulletproof Backups


Orange County Lawyer Magazine


July 2004


Jeff Lenning

SUMMARY Bulletproof backups are possible. Backing up your computer data is important, and you know that. This article strives to inspire you to action by showing you how easy and reliable backups really can be.


INSPIRATIONAL STORY There are only 3 rules of computing: (1) backup (2) backup and (3) backup. However, based on my experience, I know that people do not like to backup their data because it takes too long, is too complicated, is too difficult, and costs too much. However, the cost of not backing up your data is often times greater.

For example, one of my clients asked me to provide them with a network analysis. After my review of their network, the summary report to the client had “backup” listed as the first recommendation on the list. As it turns out, my client decided to delay the implementation of a backup solution until they had more money. That was three months ago. Well, guess who called me yesterday? That’s right. Her laptop hard disk crashed and she lost all of her data. In this case, the cost of the hard drive crash cost her much more than the preventative steps we suggested three months earlier. Hindsight is always 20/20.


EXTERNAL HARD DRIVES Fortunately for us, there is a new technology that makes backups easy and reliable: high-capacity external hard drives. The wonderful features of external hard drives are large capacity, reliability, portability and direct access to the backup files.

Historically, tapes ruled as the backup media of choice due to their high capacity, portability and ability to maintain a historical library. However, many people have struggled with the reliability of tape backups. If you were fortunate enough to have a tape backup successfully run, restoring the data from the tape often times proved difficult. In addition, if the computer with the tape backup device crashed, you would need to replace the computer and tape backup drive with a unit and software that is compatible with all of your tapes. This is too complicated and frustrating for most small firms.

The new high capacity external hard drives are a great alternative to tapes because they provide a portable device, with high capacity, and the ability to retain multiple versions of files creating a historical library. There are many brands of external hard drives. Most will connect to your computer via USB cable. When you plug the external hard drive into your computer, it is automatically recognized by your computer as another hard drive, say the “F:” drive. We frequently use the CMS brand (www.cmsproducts.com). The model we like is the Portable ABSplus model because it is powered by the USB cable, eliminating the need to have a separate AC power cable. This model easily fits into my shirt pocket, and I take it home nightly. The CMS backup software that ships with the CMS unit is wonderful.


SOFTWARE There are a variety of good backup programs on the market. Internally, we elect to use a free program that ships with Microsoft Windows called xcopy (not NT Backup). The xcopy program copies files without any compression. Programs that compress data typically create one big file. The resulting problem is that in order to restore a file from the backup, you must have the program that created the compressed file. By not compressing the data, you have direct access to the files and the restoration process is greatly simplified since you can restore a file right from your Windows Explorer. Given the high capacity of external hard drives, we do not compress the backup. Thus, we have direct access to the files and the backup process is as simple and bulletproof as possible.

The xcopy program is our preferred utility for backing up our clients’ files as well as our internal files. Xcopy is highly configurable and flexible, and thus can adapt to many backup strategies. It is worth a look. We will take a few minutes now and explore xcopy and demonstrate how to setup an automatic nightly backup.

XCOPY To use xcopy, simply open the “dos” prompt or “command prompt”, as shown in Figure 1.

Let’s setup an example xcopy command to copy all of my c:\jeff files to an external hard drive, my f: drive.

The basic command is:

xcopy “c:\jeff” “f:\”

The above command would copy files from the source (c:\jeff) to the destination (f:\).

If I wanted to copy files from a mapped drive letter (the P: drive) to my external hard drive, I would use:

xcopy “p:\” “f:\”

If I wanted to copy files from a network share that is not mapped as a drive letter to my external hard drive, I would use:

xcopy “\\servername\share” “f:\”

If I wanted to copy files from my c: drive to the p: I would use:

xcopy “c:\” “p:\”

The xcopy command provides us with various options, called “switches.” Switches provide greater control over the backup process. To learn more about the options, simply type “xcopy /?” into the Command Prompt, as shown in Figure 2.

Figure 2

Pressing the enter key will reveal help about the xcopy command. The xcopy command help file follows:

Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]…]

source Specifies the file(s) to copy. destination Specifies the location and/or name of new files. /A Copies only files with the archive attribute set,

doesn’t change the attribute. /M Copies only files with the archive attribute set, turns off the archive attribute.

/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.

/EXCLUDE:file1[+file2][+file3]… Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.

/P Prompts you before creating each destination file. /S Copies directories and subdirectories except empty ones. /E Copies directories and subdirectories, including empty ones.

Same as /S /E. May be used to modify /T. /V Verifies each new file. /W Prompts you to press a key before copying. /C Continues copying even if errors occur. /I If destination does not exist and copying more than one file,

assumes that destination must be a directory. /Q Does not display file names while copying. /F Displays full source and destination file names while copying. /L Displays files that would be copied. /G Allows the copying of encrypted files to destination that does

not support encryption. /H Copies hidden and system files also. /R Overwrites read-only files. /T Creates directory structure, but does not copy files. Does not

include empty directories or subdirectories. /T /E includes

empty directories and subdirectories. /U Copies only files that already exist in destination. /K Copies attributes. Normal Xcopy will reset read-only attributes. /N Copies using the generated short names. /O Copies file ownership and ACL information. /X Copies file audit settings (implies /O). /Y Suppresses prompting to confirm you want to overwrite an

existing destination file. /-Y Causes prompting to confirm you want to overwrite an existing destination file. /Z Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line.

Let’s say I wanted to copy files from my p: drive, including all subdirectories, to my external portable hard drive (f:\):

xcopy “p:\” “f:\” /s /d

I really like the /d switch because it tells xcopy to only overwrite the destination (external hard drive) if the file on the source (p: drive) is newer. Using the /d switch allows the whole p drive backup to run much faster than if the backup had to pull all of the files from the p drive through the network and onto my external drive every time. This saves network traffic and accelerates my backup routine to a few minutes as opposed to a few hours. The /s switch tells xcopy to copy all subdirectories too.

We can enhance the xcopy command by routing the output to a log file that we can read later. The /f switch tells xcopy to display the name of each file it copies in the command prompt window. If you would like the name of each of the files it copies to be routed to a log file instead of to the display, simply add ” >c:\log.txt”. Now, instead of displaying the file names in the command prompt window, it writes the file names to the log.txt file. This is helpful if you have automatic backups run nightly so you can inspect the log file. The revised command would be:

xcopy “p:\” “f:\” /s /f /d >”c:\log.txt”


MY STRATEGY Personally, each afternoon I plug my external drive to my USB cable, and run the xcopy command and in about 10 minutes, all files that had been changed during the day are pulled to my external drive. I unplug my external drive and put it back into my briefcase for transport home that night. Easy. Quick. Reliable. Bulletproof.


AUTOMATING THE BACKUP Let’s say that we don’t want to memorize the xcopy command and its switches, and don’t really feel comfortable with Command Prompt. We are in luck. We can save the xcopy command in a text file, give it a special name, and then simply double-click the file to launch the backup routine. This essentially creates our own little custom backup program.

Let’s say for example, that we wanted to backup two server drives, the P:\ drive and the Q:\ drive to an external hard drive. We would simply open Notepad (or Microsoft Word or any other text editor you want), and enter in the xcopy commands as shown in Figure 3. Notice all of the switches included.

Figure 3

Next, simply save this file to your desktop (or any other location that is convenient). Now, here is the trick to make it an “executable” batch file. You must change the file extension from “.txt” to “.bat”. So for example, I would save the file as “backup.txt” and then change the file extension to “backup.bat”. You will immediately notice that the icon of the file changes to a batch file icon, as shown in Figure 4.

Figure 4

Now, double click the backup.bat file to launch the automatic backup.

Now that you have the batch file, it is easy to have the batch file execute at scheduled times automatically. For example, this is great if you would like to perform a backup to another computer every night automatically at midnight.

Simply launch Microsoft Window’s Scheduled Tasks, from the Control Panel. Double click the Add New Task, and follow the wizard. When asked which program you would like to schedule, simply click the “browse” button to the location of the batch file, as shown in Figure 5.

Figure 5

By following the wizard, you can set the time and frequency that the batch file should run.

Using this technique, you can setup automatic backups to run. Some can run to another computer, some can run to your external hard drive.

One thing to understand about the xcopy command as presented above is that it will not delete a file from the destination if it has been deleted from the source. This is both good and bad. It is good in the sense that if you accidentally delete a file, it will still remain in the backup location. It is bad because your backup destination will continue to grow and grow. Fortunately, the capacity of external hard drives is large.

If you want to retain multiple versions of the files, you could always setup different batch files for different days of the week that store the data to different destination folders, for example f:\Monday, f:\Tuesday and so on. Alternatively, you could buy several external hard disks.


REDUNDANCY The best backup strategies have multiple back-ups running daily. For example, each night a backup could run to another computer and one to an external hard drive. This redundancy ensures a backup in the event that one backup routine fails. In a way, it is like having a backup of a backup.


CONCLUSION Well, hopefully this article has inspired you to set up an automatic daily backup of your data. In this case, an ounce of prevention is truly worth a pound of cure.


AUTHOR Jeff Lenning, CPA is founder of Seal Beach, CA based Click Consulting. He can be contacted at info@clickconsulting.com, or via his website at www.clickconsulting.com.

This article was written by Jeff Lenning