March 14th, 2007 in Featured, Productivity, Technology

Four ways to automatically backup your hard drive

There are many pieces of software that are available to help you backup your hard drive. However in my opinion, the simplest and most customizable way of backing up your hard drive is to do so with a homemade script. I will show you how to create a very simple script that will backup your entire hard drive on the first run. With each successive run of the script, it will only backup the files that have been modified. I will show you how to set it up so that you can backup your hard drive automatically without interrupting your work flow and without hampering any productivity. No longer will you unnecessarily lose any files again! I will show you how to do the following:

  • 1. Backup your hard drive on startup without using any extra software
  • 2. Backup your hard drive at scheduled intervals using AutomaticDailyBackup.bat
  • 3. Backup your hard drive at scheduled intervals using Windows Task Scheduler
  • 4. With the use of Xecutor, backup only the files you’ve changed on shutdown


This tutorial is demonstrated using Windows XP, however it will extend equally well into Windows Vista.

The first step is to create the backup script. The script is very short and very easy to create. First, open Notepad (Start >> All Programs >> Accessories >> Notepad) and copy and paste the following text into your Notepad file:

cd c:\
xcopy c: e:\AutomaticDailyBackup /s /e /t /h /D

Make sure that you copy the text onto two separate lines exactly as it is shown above. Also, please note that this script will backup your hard drive to an external location at e:\. If your external hard drive is located at another location, you will want to change the e:\ to a letter that corresponds to your specific external hard drive. Also, if you do not have a folder called “AutomaticDailyBackup” (I’m betting you won’t) in your e:\ drive you should create the folder manually.

Save your Notepad file with the name “AutomaticDailyBackup.bat” it is very important to include the “.bat” at the end of the file so Windows knows that it is a script and not just a plain-Jane text file. Additionally, please make sure you save the file to C:\. You can now close Notepad and you should have the file C:\AutomaticDailybackup.bat. This is shown below:

20070313-backup.JPG

This script file will be used by three of the four methods of backing up your hard drive that are shown below.

1. Backup your hard drive on startup without using any extra software

This is probably the quickest and easiest way to backup your hard drive. Right-click on your AutomaticDailyBackup.bat file and select “Create Shortcut.” After you have created the shortcut, move it to Start >> All Programs >> Startup and your hard drive will get automatically backed up every time you log in. These two steps are shown below:

20070313-backup1.JPG

20070313-backup2.JPG

In order to prevent this file from interrupting your work flow when it is backing up your hard drive, right-click on the shortcut in your “Startup” folder and choose “Properties.” In the “Properties” dialog, change “Run Normal” to “Minimized” and click “OK.”

2. Backup your hard drive at scheduled intervals using AutomaticDailyBackup.bat

The second way to backup your hard drive is to schedule an automatic backup using Windows Task Scheduler. First, you need to open Task Scheduler (Start >> Control Panel >> Performance and Maintenance >> Scheduled Tasks).

Once you launch Windows Task Scheduler, click “Add Scheduled Task” and then click “Next.” On the “Click the program you want Windows to run” selection screen, click “Browse…” and choose C:\AutomaticDailyBackup.bat and click “OK”.

20070313-backup3.JPG

Choose the frequency you would like the task to run (I chose weekly) and click “Next.” Select the day and time you would like the task to run and click “Next.” Enter your password (if you have one), click “Next” and then click “Finish.” Your scheduled task is all set and it will execute itself automatically at the day and time you chose. If you would like to backup your hard drive more frequently (for example, two or three times per week) create several tasks identical to what is shown above and set them to run on different days of the week.

3. Backup your hard drive at scheduled intervals using Windows Task Scheduler

You probably noticed that Windows Task Scheduler has a backup utility built right into it. I prefer to use the AutomaticDailyBackup file to backup the hard drive because it has a finer-grained control of the backup process. However, if you prefer, simply select “Backup” (shown below) and Windows Task Scheduler will automatically control your backup.

20070313-backup4.JPG

4. Backup your hard drive on shutdown

In order to backup your hard drive on shutdown, you need to download Xecutor. Xecutor is a free download that you can download from the Xecutor homepage. Once you install Xecutor and run it for the first time, it will ask you if you want to run Xecutor on Startup — choose “Yes.”

Next, select the “Shutdown” tab and then the green plus sign. On the properties screen, navigate to C:\AutomaticDailyBackup.bat and click “OK” (don’t worry about changing any other settings). You should see the following:

20070313-backup5.JPG

Now when you shutdown Windows, Xecutor will automatically run the AutomaticDailyBackup script.

Hopefully you found at least one of the four ways to backup your hard drive useful. Coming from someone who lost everything on a hard drive without backing up, please don’t underestimate the importance of backing up your hard drive. If your hard drive crapped out right now, how much information (documents, music, pictures, videos, etc.) would you lose?

WRITER'S BIOGRAPHY

KylePott

ARTICLES BY THIS WRITER »
Don't want to miss any related posts like there? Subscribe to our feed!

Comments

  • ray says on March 14th, 2007 at 11:29 am

    Good tip and looks almost too easy! Has anyone tried this yet? What are the drawbacks? Does it auto overwrite the previous backup?

  • Shane says on March 14th, 2007 at 11:55 am

    I don’t think this method will ensure that windows is actually recoverable from the second drive as it may not copy all the correct registry hives over to the external drive.

    It will however make sure that ALL your files are backed up and readable by any computer as it will strictly be a copy of what you had.

    I like this! Good post – just want some clarification on how to get windows boot abilities out of it.

    -Shane

  • james says on March 14th, 2007 at 12:11 pm

    Suggestion for the batch file. Look into using robocopy (from microsoft resource toolkit) instead of xCopy. It provides a lot more power and can be configured to only update changed files.

  • brandon says on March 14th, 2007 at 4:44 pm

    If u don’t want to use the 3rd party tool xecutor, you can launch scripts at shutdown using Group Policy. Start->run->gpedit.msc

    computer configuration->windows settings->scripts (startup/shutdown)

  • vis says on March 14th, 2007 at 8:28 pm

    Actually it doesn’t work. I tried it and it only copies files in c:\ and not the whole directory hierarchy. You are missing a directory structure copy option /t.

    it should be

    xcopy c: e:\AutomaticDailyBackup /s /e /t /h /D

  • LW says on March 16th, 2007 at 12:49 pm

    It doesn’t work in Vista. Vista does not include a copy of the xcopy file.

  • Macker says on March 17th, 2007 at 2:31 am

    I’ve tried this but it aborts with the error “Unable to create directory” for the first directory in my drive.

  • Benjamin says on March 18th, 2007 at 11:23 am

    I’m liking mozy.com – free backup for the first 2 gigs of your stuff. Seems to be working great so far! (and I hope they are making $ somehow.)

  • Einar says on March 22nd, 2007 at 9:53 am

    Hey, fantastic, I tried this and it works well. thanks

  • CJ says on August 31st, 2007 at 4:02 am

    i’m using too MOzy, free 2,2 giga of backup if u use this link to register. https://mozy.com/?code=GREZ68

  • Jeff says on March 9th, 2008 at 8:00 pm

    For secure backup you need the right hardware and software. Iomega’s eGo was one of TIME magazine’s “Top 10 Gadgets” of 2007 and comes with version of EMC Retrospect software for automatic backups.

    http://www.backtrackreviews.co.....dd-review/

  • Mark Ward says on March 13th, 2008 at 1:37 pm

    Will the “Four ways to automatically backup your hard drive” work for Windows 2000 as well?
    Thanks for an e-mail reply..
    Mark

  • ken rushton (MusicScienceGuy) says on July 25th, 2008 at 2:01 am

    I suggest one put a pause after the xcopy to see if the copy runs into problems.
    - with the /t option it only created the directories,
    -with the /h option it included hidden files that gave sharing violations and quickly stopped
    -without the /h option it run for a while

  • Behaelter says on August 16th, 2008 at 3:08 pm

    I believe the the /t switch sets the command to copy ONLY the directory structure (FOLDERS only) and nothing else. I don’t think that /t should be in there if you also want your FILES to be backed up as well, which I think is the purpose of the script, right? /s = subdirectory, e/ = empty subdirectory, /t = subdirectory tree ONLY h/ = hidden & system attributes set, /d [w/o parameters] = overwrite older date stamps. I just tried this to check if I stand corrected, but my new directory shows ONLY the directory structure (folders). It is just a bunch of empty directories. If the initial backup of your system happens REALLY fast, chances are your data wasn’t copied over and catastrophic damage to your drive C (or whatever drive you’re taking the time to back up) will wipe it out (both figuratively and literally) May I suggest to the author linked from this page a script (batch file) for verification that data has been backed up? A false sense of security can be more damaging than complacent redundancy. I’ll go ahead and introduce a simple approach; A simple way would be to pipe it to a text file and see exactly what is actually being copied over. For instance, if you want to see a report of all the files being copied over, I would use ” > NameOfNewTextReport.txt” at the end of the xcopy command you are going to run. It will not xcopy the files, but only tell you which files WOULD BE moved when the command is sent without the pipe. So to see which files will be backed up, you can try something like this:
    xcopy c: e:\AutomaticDailyBackup /s /e /t /h /D > c:\AutomaticDailyBackup_testRPT.txt

    So what you have is a text file in the root of C:\ called AutomaticDailyBackup_testRPT.txt that lists all of the files that will be moved when the command is used without the pipe. You can also use both in your batch file:

    @echo off
    xcopy c: e:\AutomaticDailyBackup /s /e /t /h /D > c:\AutomaticDailyBackup_testRPT.txt
    xcopy c: e:\AutomaticDailyBackup /s /e /t /h /D

    Here you see your report being generated, and then it goes ahead and does it. You can also set attributes to either replace or append to your log file (text file) if you want to keep a record of its changes. Oh, the @echo off statement just represses the commands in the cmd window declared in the script (batch file). Cheers.

  • Behaelter says on August 16th, 2008 at 3:14 pm

    Also, I used the example exactly from the original, and so I left the /t in there for that reason.

  • Behaelter says on August 16th, 2008 at 3:20 pm

    Also, the pipe command above have wrapped within the text window. The fileneame AFTER the pipe (>) is on the same line.

  • Matty S says on November 29th, 2008 at 3:17 am

    Behaelter is right about the /t. If this is in the script then the files will not be copied.

    Otherwise it’s a great tip.

    Nothing happens when I try to run the .BAT file, which I suspect is a result of the ridiculous controls my IT dept have put on my computer.

    However, the script does work perfectly well if I open the command box (START >> RUN… type in “CMD” and hit ENTER). Also, you can see what other options are available by typing “HELP XCOPY” in this command box.

    This function is good for making backups of files. However, if you change file names and/or change file structures then you will more than likely get duplicates of files & folders if you are backing up to the same backup folder. If you are making any major changes to the file structure then I suggest that you xcopy to a new destination (Maybe: AutomaticDailyBackup2) and delete the old Backup folder ONLY IF you have made sure that the new backup is succesful and you need the HDD space.

  • James Stegall says on December 4th, 2008 at 2:33 pm

    I’m trying this, but have encountered something weird. The AutomaticDailyBackup folder shows in my E drive until I restart. Then when I look in E the folder is gone, and a search doesn’t find it. However properties of E show data is there.

  • Alex says on December 6th, 2008 at 10:36 am

    I suffer the same problem as James Stegall.
    When the program runs, it doesn’t copy anything.
    When I go to E: to check, the folder “AutomaticDailyBackup” has vanished.
    Yet, when I attempt to create a new folder called the same thing, it won’t let me, as it still exists.
    So, where is the folder, and how does one get rid of it?

  • James Stegall says on December 6th, 2008 at 1:29 pm

    I can get rid of the missing folder and data by formatting E. Which I’ve done several times. However each AutomaticDailyBackup folder I create disappears after I have rebooted and the AutomaticDailyBackup.bat has run.

    A comment I ran across in another discussion group suggested that improperly disconnecting ones external drive may have caused the problem, however no solution was offered to “fix” the external drive. I am waiting for Seagate (Maxtor)to respond to my customer support inquiry.

    Also I tried Behaelter’s suggestion for the Rpt, in hopes I could know what was written to E that I cannot see. Report was created but was empty.

  • Alan Rose says on February 2nd, 2009 at 11:57 pm

    I found this article looking for ways to protect against catastrophic disk failure. Looks great — except there’s no instructions for actually recovering. Say I’ve made this lovely backup, then my disk goes up in smoke, I replace it with a brand new disk — now what? Thanks.

  • Uday Tyler says on June 22nd, 2009 at 1:21 am

    So, this doesn’t work as advertised, you need two separate lines, one to create the directory structure, and one to copy the files. Also, adding a /Y will override the overwrite prompt. The .bat file should look like this:

    cd c:\
    xcopy c:\ e:\AutomaticDailyBackup /s /e /t /h /D /Y
    xcopy c:\ e:\AutomaticDailyBackup /s /e /h /D /Y

    Great idea for the script though!

  • Madan says on July 28th, 2009 at 6:52 pm

    Thank you! It is superb, may be not for the advance users but for a normal user, the information well structured and simple to understand, once again many thanks for this article and also to others who provided the additional detail.

  • James Stegall says on August 4th, 2009 at 1:14 pm

    I used Uday Tyler’s script and I am still having the problem of the disappearing folder in my E drive.I think it copied something, my E drive was active for several minutes. Perhaps too short a time to copy 20 Gig though.

  • Ajay Aggarwal says on September 5th, 2009 at 1:21 am

    Sir, I work on Quarkxpress as a layout designer. I would like to know, when i am working on file and save it, make auto backup file in specific folder like folder name ‘Quark backup’ which is made by me in Drive ‘C’ i have tried but i couldn’t find the propper way. plz tell me.

  • Roger says on September 24th, 2009 at 9:11 pm

    This will not work for a “restore” because you miss the registry hive, and XCopy is DOS based which doesn’t support long file names. The ‘ntbackup’ utility will back up the reg hive and ‘user’ files in XP, Vista and Windows 7. However, it chokes often on 2nd and 3rd drive options, I think it’s a time out isssue and I’ve pushed it out to 72 hours, but it still can’t get to the extra drives. I love Microsoft, and hate’em too! RoboCopy is simple and have used it for years, but I can rebuild a PC in about 2 hrs so it works for me! Can you say ISO in a VM?

  • Dustley says on October 1st, 2009 at 5:01 pm

    @James Stegall

    Take out the /h. I had the same problem until I did. For those of you who can’t find the folder, you have to set your folder viewing options to view hidden folders AND view system folders. Hope this helps.

Post your comment

Continue your discussions at Lifehack Community.

Get your own Avatars at Gravatars.
Three FREE Audiobooks RISK-FREE from Audible
Recent Writers SEE MORE
Latest Poll

Do you like the new design?

View Results

Loading ... Loading ...