Backing up, inexpensive and easy
Author: jason
Date: 2009-08-12 09:33:15
Category: Technical

Backing up your computers is a good way to make certain important files and documents aren't lost. Backing up to another drive or location can ensure files are available if a computer crashes or if they are deleted. Not every backup solution is foolproof, but it doesn't have to be complex for a small business either.

External USB (Universal Serial Bus) hard drives are cheap and large. Stores like Walmart sell drives for as little as $60 for a 250GB drive or $100 for a 1TB drive. Either drive size should have more than enough space to backup critical work files, depending on usage. If necessary, one drive can be carried around to back up multiple computers, or shared out from a computer to multiple computers. Another advantage of an external drive is that it can be removed from the office for off-site storage.

For easy an backup solution we can use the XCOPY command on most computers. Or we can schedule full backups with the NTBackup software that comes standard on Windows 2000/XP. Windows Vista also has its own backup program. We don't necessarily need to buy expensive off the shelf Backup Software. Let's look at what XCOPY can do for us.

A small batch file using the XCOPY command can meet most small business needs. Create a New Text Document. Save it as Backup.BAT. The BAT extension will tell the computer this will be a BATCH file for running our commands. If we want to make a new copy of files/folders each day we can use the below sequence of commands. At the bottom of this article we'll talk about the switches used after the XCOPY command.

Keep All Changes

Set CopyFrom=%USERPROFILE%\My Documents
set CopyTo=G:\Backups\%RANDOM%
xcopy "%CopyFrom%" "%CopyTo%" /E /C /I /H /R /Y

The above CopyFrom will determine what we want to copy. I picked the My Documents folder as it is the most common place people save files. Another place would be the Desktop. The CopyTo will tell the command where to save the files. I have chosen my external hard drive, which is drive G.

Here is what the batch file looks like after it is double-clicked. I used a PAUSE command at the end to stop the batch file from exiting. Here it is backing up the My Pictures folder in My Documents.

I have picked a folder called Backups and then requested the batch file make a random folder. The random folder will let us keep "snapshots" each time we run a backup. This will allow us to revisit files at points in time. For instance, if we wanted yesterday's version of a file and it was backed up, we could find it. To see the newest version, we can sort the folders in Windows Explorer by the Date Modified.

This method will take more hard disk space as each "snapshot" is a separate copy of all the files/folders. For instance, if our files total 100MB in size then each snapshot is 100MB. If we back up every work day our total size used would be about 500MB. In two weeks it would be 1GB, on our 250GB drive. The larger the files/folders, the more space we take up for backups. This method is also a little slow as it is copying every single file, each time it is run.

Here is an example of what the backup folders would look like.

If size and speed are concerns and keeping older versions isn't important we can change the XCOPY command parameters. We'll remove the %RANDOM% and add a forward slash D.

Keep New Changes

Set CopyFrom=%USERPROFILE%\My Documents
set CopyTo=G:\Backups
xcopy "%CopyFrom%" "%CopyTo%" /E /C /I /H /R /Y /D

This version will copy all the files to one place. When the batch file is run again it will only copy files that have changed since the last time it was run. This will save space and greatly speed up the back up process.

Here is an example. The second time it was run, the batch file only copied 3 new or changed files.

Here are all the XCOPY switches available.
XCOPY Switches

xcopy /?
Copies files and directory trees.
XCOPYsource [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]
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.

Using the Scheduled Tasks applet in the Control Panel we can schedule the backups to occur automatically.

If you would like more information, please let me know. I am more than happy to provide advice and assistance.

jason @ - - copyright 2009