Create a Windows Daily Backup Script

This tutorial will show you how to use a simple Windows Batch file and the task scheduler to create an automated daily backup. We will use the date variable to backup the files into folders with the first three letters of the day as the folder name.

First you will need to open notepad. The easiest way is going to start > run and typing notepad.
Create a Windows Daily Backup Script

We will use notepad to create are batch file. A windows batch file is a set of instructions that tells the computer what to do. All we really need to do is add the command to copy the folder that we want to backup. I have a folder called ‘test’ that I want to backup to a folder called ‘backup on a network drive which I have mapped as the x drive. It only takes one simple command to do that actual backup. (note: there is no | in the command next the the word date, that is just the cursors)
Create a Windows Daily Backup Script

Now I will explain the command “xcopy c:\test\* x:\backup\%date:~0,3%\* /Y /Q /S”

The xcopy commands will copy files and folders. The syntax for the command is xcopy [destination] [arguments]. Where source is the folder that you want to backup and destination is the backup on the network drive. The arguments tell xcopy how to handle certain situations. For my script I used /Y to suppress prompting when overwriting files. If you do not include this the script will ask you before copying each file, that wouldn’t be automated. /Q doesn’t display the file names while copying. /S copies directories and sub directories. You can find more arguments by opening the command windows and typing xcopy /?.

Where you see \%date:~0,3%\ is the name of the destination folder. If you didn’t want to change the name daily you could simple call it \backup\ or something like that. The %date% is a variable. If you type %date at the command line, you will get the current date and time output. The :~0,3 tells the command line to return the first three letters of that date (0-3) and trim off the rest.

Once you have made the changes that you nee, save the file as backup.bat
Create a Windows Daily Backup Script

Now Open the Control Panel and select Scheduled Tasks
Create a Windows Daily Backup Script

Now we want to add a new task so click the “Add Scheduled Task” button.
Create a Windows Daily Backup Script

Click next and then browse. Locate the backup script you just saved and click open.
Create a Windows Daily Backup Script

Select perform this action daily and then click the next button.
Create a Windows Daily Backup Script

Select enter the time you want the task to run at in the start time box. Then make sure daily is selected and change the date to the day you would like this task to start running on.
Create a Windows Daily Backup Script

Enter your password and click next. (note: if you do not have a password, you may have problems with the scheduled tasks running correctly. I recommend adding a password to your account, or setting up a separate account to run scripts.)
Create a Windows Daily Backup Script

Click finish. Now we can test the backup script. Located the script in the scheduled tasks folder, Right click it and select run.
Create a Windows Daily Backup Script

You should see the command window open. When the task is finished, browse to your backup folder and verify that the files have been copied.
Create a Windows Daily Backup Script

This is a very basic idea of how to use the task scheduler and batch files to make backups.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join the TeamTutorials mailing list and get the latest tips, tricks, and special discounts for members only.

Thanks! Please click the link in the email we just sent you to confirm.

  • sandesh

    i am unable to copy all files & folders, if i run the script only one files is copying.

  • Look at the first part of the command. In my example it is copy c:\test\*

    Make sure that you use the asterisks(*). It is a wild card that tells the command to copy everything in the folder.

    You could also use the * to copy all of a certain type of file. For example copy *.jpg would copy all jpg files.

  • Dave

    This is just what I was looking for except that I need to have the whole date recorded in the folder name, preferably ‘year_month_day_backup’. When I run your script without limiting the output from date, I recieve the following error:
    \Wed 05/23/2007\* /Y /Q /S
    Invalid number of parameters

    Obviously a format not allowed!

    Can you help me achieve what I need to do?

    Thanks

  • Dave

    Anybody out there able to answer this please?

  • %date:~0,3% That tells the script to out put 3 characters from the 0 space. So you could tell it to out put the year by using the characters. (%date:~10,4%) and then do the same for the day and year.

    Try this at command line.
    echo %date:~10,4%_%date:~4,2%_%date:~7,2%_backup

    Hope that helps. Sorry it took so long to get back to you, I didn’t understand the question at first.

    • sandeshm

      thank you John Ward…
      its working fine and as i wanted.
      thanx again.

  • Dave

    Perfect!
    Thank you John!

  • Jim Barbera

    For the folder name as date to work, you need to change the date format in regional settings to replace slashes with dashes.

    I also rearranged the short date format to YYYY-MM-DD since that’s how I name all folders as dates. This way, alphabetical filename sorting will produce a neat list in chronological order top to bottom.

    Here’s how. Click the following:

    Start
    Control Panel
    Regional and Language Options
    Regional Options tab
    Customize button
    Date tab
    Short date format: select yyyy-MM-dd
    Date Separator: select “-” (Dash) or “.” (Dot) if you prefer.
    OK
    OK

    My backup batch file to back up My Documents, Firefox, and Email looks like this:
    xcopy C:\docume~1\user\MYDOCU~1\* I:\Backup\”%date%”\My_Documents\* /Y /Q /S
    xcopy C:\docume~1\user\Desktop\* I:\Backup\”%date%”\Desktop\* /Y /Q /S
    xcopy C:\docume~1\user\APPLIC~1\Mozilla\* I:\Backup\”%date%”\Mozilla\* /Y /Q /S

    Hope this helps.

    -Jim Barbera

  • Bin

    Hi,

    Am able to do something like this at all?

    xcopy \\server01\Test\* etc…..

    I really need this….

    Thanks

    Bin

  • Bin,

    I don’t see a problem with using a UNC address when copying. Have you tried it?

  • Bin

    I tried it but hasnt worked for me. Thought that it may not work for UNC paths. Any chance you would be able to confirm?

    Many Thanks

    Bin

  • Yes. UNC copying works for me.

    • Amman

      Dear
      i want a log file after backup that ensure that all files are copied or Not,and errors.
      Thanks in advance
      im using below script:

      echo %date:~10,4%_%date:~4,2%_%date:~7,2%_backup
      xcopy D:\dbbackup\* J:\dbbackup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup%\* /Y/Q/S

      • Raju

        i want a log file after backup that ensure that all files are copied or Not,and errors.

        Thanks in advance

      • Mail2sid2008

        this cmd is nt working on window7
        plz tell me for windows7

  • Bin

    Hi, Many thanks. I will check why mine is not working.

    Thanks

    Binesh

  • Jim Barbera

    Thanks John Ward! Your explanation of the Date naming function now makes sense. I was having trouble figuring it out. Here’s what I came up with…

    If you don’t want to change the date format on your machine, you can set up the date naming function like this:

    Instead of
    %date%

    Use
    %date:~10,4%_%date:~4,2%_%date:~7,2%

    To back up your My Documents folder to the “I” drive, your line would look like this:
    xcopy C:\docume~1\user\MYDOCU~1\* I:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%\My_Documents\* /Y /Q /S

    This will result in a valid backup folder name as YYYY-MM-DD.

    -Jim

  • Scott

    Thanks, good tip. UNC worked fine for me as well. I used this to copy from one server to another where the backup tape resides

  • thib´

    Hi,

    For more advanced users, don’t forget that WinRAR has command line features (use “rar.exe /?” and “unrar.exe /?” in the WinRAR installation directory). You can then auto-archive your backups to save place. Also, I recommand GnuPG for encryption (which is also essentially CL). I don’t have much time to write a full script here (actually just thought of it after seeing this great tutorial), but by reading the doc and help files of each software, I’m sure you can make a good auto-backup-packager-encrypter without any difficulties ;).

    -thib´

  • Great suggestion thib. Adding a win rar command would be a good idea. We also used pkzip on my last job to do some backup scripts.

  • Ken Allen

    i’m trying to set up a batch file for each day of the week and then an overall weekly backup. so i have various folders set up. i’m having trouble using the date variable to find the files that have been modified that day and copy them to the appropriate folder. the beginning of my batch file looks like:

    @echo off
    :: variables
    set drive=F:\backups1_monday
    set backupcmd=xcopy /s /c /d:%date% /e /h /i /r /y

    but it bombs because %date% wants to return Tue August 14, 2007 and d:Tue doesn’t mean anything.

    any ideas? sorry for being a newbie – thanks for the examples to work from as they have been very helpful.

  • What are you trying to copy from? Is the folder named tuesday? I didn’t really write this script to copy only files that changed on a certain day. The purpose is to do a full backup daily and then name the back up whatever that date is. Then you could do a backup at the end of the week and back all those up and name it.

  • Joseph Abasolo

    Great help! thanks dude ^_^ , im currently backing up daily and my script only has
    a xcopy command. AHU! AHU! AHU! (spartans)

  • balwinder

    your command help me lot, but i am need time to display

  • balwinder

    please help me——this command help;s me but i want me file name should be

    i.e. 2007_08_20_12:20:20

    i.e. YYYY_MM_DD_HH:MM:SS

    please held

  • To Balwinder
    This command can easily be replaced with the time variable. This is a system variable and you can call it using %time% just like I did with the date. Then you will need to adjust the format using the ~and select the characters as shown in the tutorial.

  • @balwinder again. Where you see %date% that will display the default date for your system. So mine will display: Wed 08/22/2007. So for example if you want to display the year, it would be something like %date:~10,4%. That is telling the script to display only from the 10th position (the position is the space in front of the character, so starting in front of the W will be position 0, count over to the space in front of the character you would like to use) and the 4 tells our script to display 4 characters after the selected position(10). I don’t have time to test this so I will give it a shot, you will have to adjust the code as needed. Your code would look something like this (if you have standard us date/time settings for the environmental variable):

    xcopy c:\WhatYouWantToCopy C:\BackupFolderName\%date:~10,4%_
    %date:~7,2%_%date:~4,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%

    * No spaces. I had to add one to fit it in the comment box on this website. I had to replace your colons (:) with underscores (_) because a colon is not a valid character in a Windows folder name.

  • Balwinder

    hi

    sorry, John Ward, your script contain error please check at your end

    and get me a solution to —– folder name as

    c:\2007_08_20_12:20:20\

    i.e. YYYY_MM_DD_HH:MM:SS

  • I already explained to you that YOU CANNOT USE A COLON (:) TO NAME A FOLDER. This not a valid character for a windows folder name. Replace it with some other character. I am not going to rewrite the script. I am sure you can figure it out.I didn’t write this tutorial so I could write everybody’s backup script for them. I have no problem answering the occasional question, but I am not going to do your work for you. If you follow this tutorial and read through the comments you should have no problem creating your own version of the script.

  • balwinder

    hi

    sorry, John Ward, your script contain error please check at your end

    this is not a matter of

    COLON (:)

    please check

  • Read the tutorial again, you can figure it out.

  • Damany Harden

    Is there any way to exclude files or folders in the script? For instance I want to backup the My Documents folder but not the My Music folder inside My Documents.

    Thx in advance

  • Thats a good question. You may have to do each folder separately. I will look into that though and try to get back to you.

  • Damany Harden

    This script is diabolical – It answers the question of excluding folders and more. It is pieced together from a variety of sources and modified for my need. The modifications are easy to fit anyone’s need.
    ———————————————————————————————————–
    ::set username if you are mounting to a network drive or some location that
    ::requires a username and password. In this case it is using the windows ::account password

    set USER=xxx

    ::mount drive – I am mounting a network drive and map it to the U drive.
    ::The start /wait allows time for the drive to mount before moving on to the ::next process

    start /wait NET USE U: \\(your_server)\(some_directory) /USER:%USER% ‘password’

    @echo off
    ::create a file with a running list of directories, files and/or file types you ::want to exclude. In my case I want to exclude certain folders. See ::further down example of exclude file. I copy the exclude txt file to a tmp ::file just incase the txt file gets caught up in some other process. I save ::the exclude txt in my docs because I want to back it up as well, so I will ::always have a up-to-date copy with each backup.

    copy “%USERPROFILE%\My Documents\exclude_folders.txt” exclude.tmp

    :: variables
    set drive=U:\.backup
    set folder=_%date:~10,4%_%date:~7,2%_%date:~4,2%
    set backupcmd=xcopy /s /c /d /e /h /i /r /y /v

    ::My Documents has its own variable because of the exclude. I don’t want ::certain directories to be backed up. here is where the exclude file is ::called

    set mydocbackup=xcopy /s /c /d /e /h /i /r /y /v /exclude:exclude.tmp

    :: THE BACKUP
    echo ### Backing up My Documents…
    %mydocbackup% “%USERPROFILE%\My Documents” “%drive%\My Documents%folder%”

    echo ### Backing up IE Favorites and Firefox Bookmarks…
    %backupcmd% “%USERPROFILE%\Favorites” “%drive%\Favorites%folder%”
    %backupcmd% “%USERPROFILE%\Application Data\Mozilla\Firefox\Profiles” “%drive%\Mozilla%folder%”

    echo ### Backing up email and contacts (MS Outlook)…
    ::%backupcmd% “%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook” “%drive%\Outlook%folder%”

    :: use below syntax to backup other directories…
    :: %backupcmd% “…source directory…” “%drive%\…destination dir…”

    del exclude.tmp

    ::Disconnect the mapped drive
    start /wait NET USE U: /DELETE

    echo Backup Complete!
    @pause
    ———————————————————————————————-

    This is my “exclude_folders.txt” content in the exact format

    My Documents\My Music
    My Documents\My Pictures

  • Damany Harden

    Script without all the comments

    set USER=xxx

    start /wait NET USE U: \\(your_server)\(some_directory) /USER:%USER% ‘password’

    @echo off
    copy “%USERPROFILE%\My Documents\exclude_folders.txt” exclude.tmp

    :: variables
    set drive=U:\.backup
    set folder=_%date:~10,4%_%date:~7,2%_%date:~4,2%
    set backupcmd=xcopy /s /c /d /e /h /i /r /y /v
    set mydocbackup=xcopy /s /c /d /e /h /i /r /y /v /exclude:exclude.tmp

    echo ### Backing up My Documents…
    %mydocbackup% “%USERPROFILE%\My Documents” “%drive%\My Documents%folder%”

    echo ### Backing up IE Favorites and Firefox Bookmarks…
    %backupcmd% “%USERPROFILE%\Favorites” “%drive%\Favorites%folder%”
    %backupcmd% “%USERPROFILE%\Application Data\Mozilla\Firefox\Profiles” “%drive%\Mozilla%folder%”

    echo ### Backing up email and contacts (MS Outlook)…
    ::%backupcmd% “%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook” “%drive%\Outlook%folder%”

    :: use below syntax to backup other directories…
    :: %backupcmd% “…source directory…” “%drive%\…destination dir…”

    del exclude.tmp

    start /wait NET USE U: /DELETE

    echo Backup Complete!
    @pause

  • Momo

    Anyway to have this run more than once a day?

  • The only way I can think of to have it run multiple times a day is to set up several scheduled tasks. For example you can have 1 run everyday at 1pm and 1 run every day at 1am. I don’t think windows task scheduler has an option to do hourly. Maybe a third party scheduler would do the trick?

  • abazari

    Hi tanks for Help
    For Create Zip File Name From Date System You must Install “Command Line Support Add-On” on winzip 8 or 9 and cerate a .bat file exclude:
    ———
    Path \\computer1\e$\Backup_Commander\WinZip
    wzzip -P -r -m -Jhrs -whs \\computer2\d$\Zip_Surce\%date:~10,4%_%date:~4,2%_%date:~7,2% \\computer1\e$\Backup\*.*
    —–
    this command cerate a zip file from current date and move data in this zip file

  • Fantastic posts I am highly impressed and if you could guide me to a list of system variables and commands available in dos.

  • Strojki

    hi i have a question i already tried this backup but it said invalid number of parameters what should i do ?? Tnx in advance

  • shawn

    Am I missing something or is not using the veritas backup utilitiy built into win2k and xp easier to config and use?!?!?!

  • Anand

    Thanks John!!!!!

    It worked great….

  • please help to archive the given file in the window

  • ikraam

    Hi

    I am trying to copy a ……\backup\*.bak file from MSSQL to another folder on the mapped network drive but i am having an issue that it does not copy the .bak file to another folder even if the destination folder is on the local drive
    (xcopy c:\……\backup\*.bak z:\Backup) that is the command line that i am using.

    I am guessing with my little knowledge of script writing that this is incorrect as its not working?LOL

    Please i need a little assistance in regards to get this working

    P.S. i even stopped the service of SQL to make sure that the program is not using the .bak file while copying the file but that too does not copy the file over

    your help will really be appreciated
    Thanks

  • peter

    hi john,
    I have an issue. I need to backup at three servers whoes date format are different from one another.

    I there any other option so that If I run the backup batch file once, it should backup the source data to the target folder say sunday (folder name) and similarly if I run the same batch file the next time it has to automatically backup the source data to another folder called monday and so on… for the entire week (7 days). I use xcopy …. but no clue how to achieve it.

    Pls help . thanks

  • I’ve written something similar to this , but more advanced.
    I add some simple lines of code to add backup folder like this
    \yyyy\mm\dd\backup
    and also generate a log file
    Check my post out:
    http://zangoole.com/1387/07/07/batch-backup-script/
    Unfortunately It’s Farsi (Persian) but take a look at the code.

  • Pingback: با نت پد یک پشتیبان‌گیر حرفه‌ای بسازید | ساخت یک بک آپ گیر اتوماتیک با نت پد | ترفند | آموزش()

  • Look at the comment above, he’s an Iranian…

  • mitch
  • mitch

    what is backing up files good for and y do ppl do it??? plz hlp hehe

  • Scott

    Thanks for the help, really great guide you have going here.

  • Killer

    Didn’t quite see the answer to the question regarding backups of “newest” files.

    I want to create a copy of a music directory and then run your script nightly so that if there are new mp3 files added to the source directory it will only copy those files.

    Any ideas?

    Thanks in advance.

  • how to copy directory from one location to another location using xcopy in windows

  • Ben Kennedy

    Hi John,

    Just wanted to let you know that you are on stumble upon.

    I like your script!

    A word to everyone who needs help making their own scripts: Please stop asking John to write a script for you, do it yourselves, it’s not hard. You can easily use any search engine to research the various commands in this script to find out how it works. Do your homework first, and then you won’t have to ask silly questions that aren’t worth the time to answer.

    Anyway, Keep up the good work John.

    -Ben

  • cicciux

    or, simply use ntbackup or any of the thousand backup tools out there.

    nice post though.

  • san

    This is not working @ time 12:00 AM

    xcopy D:\xyz\* D:\Backup\%date:~10,4%-%date:~7,2%-%date:~4,2%_%time:~0,2%.%time:~3,2%\* /Y /Q /S

  • Hi Everyone,
    I have found that, if you are trying to copy a folder that has space in name (Example: Documents and Settings), then this script will not work.
    To make it work:
    You will have put quotation mark on both ends of folder’s address.
    Example:
    xcopy “C:\Documents and Settings\Administrator\Desktop\*” “\\server\admin\Backup\Hp-Desktop\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\*” /Y /Q /S
    This script working perfectly on my pc, and I hope it will work on your too.

  • I have found that, if you are trying to copy a folder that has space in name (Example: Documents and Settings), then this script will not work.
    To make it work:
    You will have put quotation mark on both ends of folder’s address.
    Example:
    xcopy “C:\Documents and Settings\Administrator\Desktop\*” “\\server\admin\Backup\Hp-Desktop\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\*” /Y /Q /S
    This script working perfectly on my pc, and I hope it will work on your too.

  • Jim Barbera

    You can copy folders with spaces in the names. You just have to use the folder’s MS-DOS name in your command lines.

    Examples:

    My Documents = MYDOCU~1
    Program Files = PROGRA~1
    Application Data = APPLIC~1

    To find the MS-DOS name, you’ll need to open a command prompt window and navigate to the folder using the dir /X and cd commands. Maybe there’s a better way, but this is what I do.

    -Jim

  • Pawandeep, I had the same trouble. Tried differentcommands for hours until I came across your post. Thank you thank you!!!

  • Awesome tutorial, I always converted my bat to an exe then added it to start up as I didn’t realize there was a scheduled task feature.

  • I think this is valuable to anyone running windows, because of course it fails so much. Thank you.

  • This has been really helpful. I have been using it ever since. Thanks.

  • very easy to follow tutorials, thanks for this, i will implement it right now to my computer

  • Nicole

    Hey John,

    This tutorial was very helpful. I am working on getting a back up scheduled and running it as a batch file might actually work. One question I have those is that the folder that I am attempting to back up is buried deep into some folders. Am I able to write it so that it copies automatically just that file or do I have to do the long string of A folder to B folder to C folder etc?

  • Ron Tadle Jr.

    hi

    john ward you are the best here

    keep up the good works

    thanks

  • Niklas

    donno if anyone said this before but if you need to copy a file with space, you can also use “” , then you don’t have to use the dos name (ex: “c:\my folder with space”) thank you for the tutorial! was the solution to my windows backup problem.

  • Vinodh

    Hi,
    I was try fallowing script is not work. Please help me…

    “xcopy c:\test\* x:\backup\%date:~0,3%\* /Y /Q /S”

  • Vinodh

    Hi,
    Sorry. It’s working.

  • Pingback: Anonymous()

  • i still have to do some efforts for this..

  • please help me.. it is still not working

  • I agree Niklas.Thanks.

  • darren

    How do you make the script back up only updated files? Here is what I am using currently
    xcopy “C:\Documents and settings\Darren Morris\My Documents\My Pictures\*.pdf” W:\backup\darren\%date:~10,4%_%date:~4,2%_%date:~7,2% /Y /Q /S

    Right now it backs up the same files over and over.

    thanks

  • Steve P

    I am using the following from my desktop to a network drive that I’m mapped to. It does not run. No error, no status update. Shows that it starts, but nothing. I tried creating the folders in Backup directory. All permissions are right. No “Read Only” files or folders. Any ideas what might be causing it to fail? I’m a novice but it looks like it should work.
    I used no designator “P*” and it didn’t work then either. I just want to backup folders in the student_data directory that start with P.
    Thanks.

    xcopy \\A6181sbusedd\student_data\P* \\A6181sbusedd\student_data\Backup\* /Y /Q /S

  • Padre

    batch working perfectly well but i nid to know how to exclude multiple file types at the same time like .mp3, .wma and .pdf at once

  • Mohamed Kheir

    Dear John Ward,

    I have a folder on my desktop called 2009-2010 (C:\Users\mohamed Shamaly\Desktop\2009-2010) and the same folder is in my external harddisk F:\2009-2010
    I used to have this command and it was working (Xcopy “C:\Users\mohamed Shamaly”\Desktop\2009-2010\* F:\2009-2010\* /Y /Q /S) but today it didn’t work. I changed it to this (Xcopy C:\Users\”mohamed Shamaly”\Desktop\2009-2010\* F:\2009-2010\* /Y /Q /S) but now it get a screen and it takes time to backup but before it just used to blink quickly.
    please help

    • Mark

      Mohamed,
      You should put quotes around the whole file path not just your name e.g. “C:\Folder with spaces\*”
      so in your case the correct syntax would be:

      Xcopy “C:\Users\mohamed Shamaly\Desktop\2009-2010\*” F:\2009-2010\* /Y /Q /S
      Pause

      You will see a put a Pause command at the end of your script. The pause command keeps the black command window open for you to press a key after the script has completed. This allows you to see any reported errors. If there are errors in your scripts you won’t see them without the pause statement. Once you are happy that your script is working correctly you can remove the pause command.

      Mark.

  • rsbrux

    To all who asked how to backup only new files,
    use “XCOPY /D”. These questions and many others
    posted here can be easily answered by simply running
    “XCOPY /?” in a command window as John has suggested,
    and examining the available options.

  • DEMETRIOS

    Hi guys I have one problem. I can make the script run but the version of windows I want to use it at is in Greek Language and the name of the folder is in Greek. The batch file will now recognize the Greek name of the folder. I have to load some type of program before to make the batch file recognize Unicode? I can’t get it to work… Any suggestions???

    • Some random guy

      Demetrios, I know you may not even come back to read this but you can actually input the ASCII for the character you are trying to enter (I am guessing you have the Greek Language installed on the computer) I am sure you can find the ASCII for your specific character by doing a google search. (dont use bing though, I hear it breaks your computer 😉 jk

  • i need to copy file start with FA01752010 but that file change daily with new date how can i create batch fo fix this issue

  • Greg

    I’ve been playing with this a little, but each time, I run it I get the following:

    Does c:\backup\10-05-27blah.txt specify a file name or directory name on the target
    (F = files, D = directory)?

    and waits for my input, which is not good for something I want to run automatically and invisibly.

    I want to backup a single file each day, and rather than making a new directory for the file, I was just appending the date to the front of the filename.
    The /I switch for xcopy assumes directory, but there doesn’t seem to be an alternative for assuming file
    any ideas anyone?

  • Gerry

    I just created my first ever automated script after reading all the above posts and Wow it’s so simple!

    In reply to the following post:

    John Ward on September 28, 2007 at 3:05 pm
    The only way I can think of to have it run multiple times a day is to set up several scheduled tasks. For example you can have 1 run everyday at 1pm and 1 run every day at 1am. I don’t think windows task scheduler has an option to do hourly. Maybe a third party scheduler would do the trick?

    You can effectively repeat the script every X minutes if you want. You just have to right click the script in the scheduled task(propreties) and in the second tab, you click the “advanced” button! Voilà!

    GREAT POST!

  • KKarina

    I have a problem with Windows. I deleted by error the following:
    Key: HKEY_CLASSES_ROOT\.psd\(deleted key)
    HKEY_CLASSES_ROOT\.tga\(deleted key)
    If you are running Window NT/2000/XP/Vista, please log on with administrator privilege.

    Because of this, I am having problems with an embroidery software. Help, please.

    • Gerry

      just do a system restore to a time and date previous to the deletion of those lines in the registry.

  • Jeremy

    No questions from me, the script is bonza!
    Thank you

  • ayunk

    how to make backups polders with a different name, every time make a backup without having to overwrite
    thank..

  • Madhavi

    Its a great forum !!! Thanks for all the posts.

    I have one question:

    We can take daily backup of folders using Xcopy command, its ok. But the thing is that is there any way so that we can repalce the old backup foldrs by new one? What i want is that if we tok backup for 5 days , on 6th day it shld replace 1st days backup folder instead of creating 6th folder at destination.

    is that possible? Please suggest.

    I used this command to take backup:

    xcopy r:\pd\r64bap2\* c:\backup\r64bap2\%date:~0,10%\*/y/q/s

  • Gus

    What I want to do is backup excel files daily on a flash drive. My files are on C:\data\excel and my flash drive destination is on G:\excel. It could activate through the schedular, but it would be better if I could initiate it manually through an icon. Please help if you have time.

    Thank you
    Gus

  • Aars

    Hi John

    I really like your script, but i want output in zip or rar format?i mean compressed formate. can you please help me to do this?

    or anybody? Thanks

  • Jim

    This script gave me a raging boner that cannot and will not be tamed.

  • David

    Question: is it possible to find the day of year and format the file name to eg: Monday001 (Monday Jan, 1), Tuesday002 (Tueasday Jan 2) and so on?

    Thanks in aticipation.

  • Nisar

    Thanks john ward , your script is so helpfull.
    I have a Question. how to backup a folder from remote computer through Script.
    could you help me please.

    thanks

  • install this software..

  • Pingback: Daily Backup « bss2011eal()

  • Pingback: Daily Backup for Windows 7 & Linux (Rsync) | EAL IT technologist (2010 Autumn)()

  • Homayoon Fayez

    Thank you John, it was a great help

  • Tubz

    Can you copy the whole drive as well? Im assuming its just xcopy C:\* (Right?)

  • okiekaren

    Hi, I am a newbie but need to write two batch files. I need to do a nightly backup, perhaps about 1:00 in the morning. It needs to backup from my store to my home server remotely. My server has an https:// URL, then I have to login using an ID and password. How can I write a batch file that will log into my home server via https:// and then back up? Or, maybe using an ftp program (automated)? Or I am open to other ideas.

    Another batch file I need is to simply kill a program (instead of teaching my mom to use Task Manager) and open it back up. For the time being, I have a POS system that freezes if a VOID is made. If I could give her a button to push to just close the program and re-open it, that would be super!

    I have been reading through this forum and it is great. Thanks for all the valuable input.

  • Vikram Singh

    Try robocopy its better than any other backup program.

  • Someone set this up for me and after a while it quit running..can you tell me what I can change to get it to work again. There is a short cut on my desk top and it was so easy to just double click and it would back up to my external drive. Thanks for your help.

    xcopy “C:\Users\Msvikk\Documents” “J:\My Documents” /d /e /f /h /r /y
    xcopy “C:\Users\Msvikk\Pictures” “J:\Pictures” /d /e /f /h /r /y
    xcopy “C:\VikWing” “J:\VikWing” /d /e /f /h /r /y
    pause

  • zoozoo

    hey its awesome….
    than q….

    anyway i’ve designed this kind of script

    Robocopy C:\Users\Dr\Documents\ E:\123\123\ /S /XO /NP /LOG:documents/Q &
    ROBOCOPY C:\Users\Dr\AppData\Roaming\Mozilla\Firefox\Profiles E:\456\123\ /S /W:0 /R:1 /XO /LOG:firefox /NP &
    Robocopy C:\Users\Dr\Desktop E:\789\123\ /S /MIR /LOG:desktop /NP

    the only drawback is the console..it is prompting and i don’t like it… is there anyway to hide the console.. ?? than q..

  • Paa

    Hello Guys
    Anytime I run the script I can see my backup on the destination drive but will immediately varnish when I close the command prompt.
    What is wrong with my script.

    Also how I make command prompt exit after completion of task.

  • Juno227

    I am new to backing up folders and directories.  I have Windows 2008 server that I need to copy a folder to the backup folder everynight.  I need to keep a copy of back up.  Can you assist me.

  • Andreas

    This is all useful information and seems simple enough to implement.  What I found most helpful though is using the server management website 
    http://scalextreme.com/.

    These guys do everything for you.  You can simple copy and paste certain scripts for your Operating System and the free trial version automates the script for you.  You can even create a template which allows you to create a multitude of maintenance scripts which runs every week!  Neat stuff.  Just giving me two cents on what helped me with handling my Amazon EC2 servers.

  • Pingback: backup script | Script Nulled()

  • Doug

    I don’t know if you still read these comments, but I just wanted to say THANK YOU! I’ve look long and wide for this simple, elegant solution. It’s perfect!

  • gaurav

    thanks bro
    that is what i was looking for

  • Pingback: Ftp Backup Script | healthxfood.com()