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?

  • ray

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

  • Shane

    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

    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.

  • Pingback: Drainedge Link Tank · Today’s Links

  • brandon

    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

    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

    • Sabu

      yes

  • Pingback: The Poulette Family » links for 2007-03-15

  • LW

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

  • Macker

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

  • Benjamin

    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.)

  • http://www.cutdiamondmedia.co.uk Einar

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

  • CJ

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

  • Pingback: Data Security: 29 Services and Techniques to Backup Your Hard Drive | Vandelay Website Design

  • Pingback: moneyblog » Data Security: 29 Services and Techniques to Backup Your Hard Drive

  • http://backtrackreviews.com Jeff

    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.com/2008/02/11/iomega-ego-portable-hard-drive-hdd-review/

  • http://N/A Mark Ward

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

  • http://MusicScienceGuy.vox.com ken rushton (MusicScienceGuy)

    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

    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

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

  • Behaelter

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

  • http://www.mtolympus.co.nz Matty S

    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

    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

    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

    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.

  • Pingback: 60+ Ways to Improve Your Productivity as a Designer | Outlaw Design Blog - A Graphic Design Blog

  • Alan Rose

    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

    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

    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

    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

    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

    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

    @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.

  • Jim

    The /t is a huge problem. The author needs to CORRECT THE ARTICLE, otherwise someone is going to trust that the article provides a backup, which it doesn’t. I understand that you made a mistake, but good grief! Just admit your mistake and fix it!

  • http://kriskoster.com Kris Koster

    Why don’t you guys just buy NovaBackup and be done with it?! A few years ago, this simple script would have been super great, but it’s basic compared to some of the features available in today’s intuitive backup software.

  • http://www.squidoo.com/easy-backup-wizard- easy backup wizard

    this is awesome..I love that you don’t have to buy anything…i am going to do some more research on it before i get started

  • CasualNerd

    I searched for a script to BACKUP/RESTORE my RAMDRIVE at SHUTDOWN/STARTUP…(oh yes xcopy ofc)

    However “xcopy c: e:AutomaticDailyBackup /s /e /t /h /D” does NOT work for me – You might use /s or /e and /t only copy structure,no files imho…better check “XCOPY /?” for explanation of parameters?!

    MY SCRIPT looks like this(without “cd c:”):
    xcopy R:RamdriveRoot “C:Ramdrive Autobkup” /D /E /H /K /Y <– BACKUPSCRIPT
    xcopy "C:Ramdrive Autobkup" R:RamdriveRoot*.* /E /H /K /Y depending your system/country?
    2. Use “” if folder names contain spaces (like “Ramdrive Autobkup”)
    3. If i dont use *.* , xcopy stops and asks if “RamdriveRoot” is folder or file

    4.USE GPEDIT ! no 3th party software as s.o. mentioned before. Just click Run->gpedit.msc->”Windows startup/shutdown Scripts” (Its maybe only win xp pro but you can download it aw)

    Works perfectly,regards:)

  • Mary

    Thank You For Your Help. It has been several years since I was on a computer and I have forgotten a lot as well as the system has changed so much. Thank you again.

  • Mortice80

    Set the backup as suggested but documents file and program files don’t backup??

  • James Geek

    Thanks for sharing, if you want to save your time you can use backup software like Handy Backup, it’s easy to use automatic backup software. 

  • Guest

    Will this work for a network drive?

    • Guest

      If it’s properly mounted

  • Steve

    I kept getting a message saying “you don’t have permission to do this”

  • Nate

    xcopy c:* h:backup /Y /Q /S

    That will copy your C: drive to the specified folder, H:backup for me. 

    Short, sweet, and to the point.

  • Anonymous

    A dumb question-Is there a simple way to schedule a back up without duplicating all that has gone on before? In other words, without copying the entire c: drive over each time the back up program runs? I have a Buffalo external drive that I filled up and abandoned because of the duplication. 

  • Anonymous

    If I need to backup drives other than c, for example if I need to backup files on a particular drive on my network, can I just replace c with the letter for my shared drive of choice and run this script> Will it work?
    Thanks,
    JS

  • http://www.facebook.com/JeremyDonna.Weaver JeremyNdonna Weaver

    Your script does not copy files that have not been modified since the last time it ran, only ones that have been modified or added, and that is good – takes much less time.  However, if something is deleted on my C drive, will this also remove the file or folder on my backup drive.  If not, how would I accomplish that?
    Thanks

  • http://www.facebook.com/manugowdars Manu Gowdar S

    Now when you shutdown Windows, it will not automatically run the AutomaticDailyBackup

  • Satheesh A

    I have number of folders in my backup.. I need to separate these files
    and put into newly created folder according to their category.. But i
    need to done everything automatically both separation as well as new
    folder with category name…

  • Satheesh A

    I have number of folders in my backup.. I need to separate these files
    and put into newly created folder according to their category.. But i
    need to done everything automatically both separation as well as new
    folder with category name…

  • Satheesh A

    I have number of folders in my backup.. I need to separate these files
    and put into newly created folder according to their category.. But i
    need to done everything automatically both separation as well as new
    folder with category name…

    Example:

    I have a Folder Name as xxxxx

    I Need to be as YYYYYY_—> xxxxxx.

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM

  • http://profile.yahoo.com/V2UAZI7CXVGQFGDUBZY4EYNKI4 ROCKY-TIGER KING

    SKYPE=ROCKY-TIGER-USA YAHOO-YM=ROCKY_TIGER@ROCKETMAIL.COM MSN LIVE=TIGER_0717@HOTMAIL.COM MSN LIVE=ROCKY_0717@YAHOO.COM MSN LIVE=ROCKY-TIGER@WINDOWSLIVE.COM QQ=859061471 AOL-AIM=ROCKY_TIGER@AOL.COM